Re: Tilde expansion on (Windows)files?



On Sun, 2 Aug 2009, Gerald W. Lester wrote:

Gerhard Reithofer wrote:
Hi,
working on a storage optimization system (millions of files) I realized,
that a tilde in a filename makes problems:

Tcl 8.5.4, Windows XP - test:
(gerhardr) 4 % set fl [glob y:/WinXP/*]
{y:/WinXP/~$obkonzept_tech.doc} y:/WinXP/E1007029.exe
y:/WinXP/ricohmemory_xp (gerhardr) 5 % foreach f $fl {puts [file type $f]}
could not read "y:/WinXP/~$obkonzept_tech.doc": no such file or directory

What does this mean, which filename is searched?
If it works on Windows (see man page), why doesn't it find the file?

On Windows a ~$*.doc file is a temporary file that MS Word opens. This file
contains information about which user has the file open, to prevent multiple
users from attempting to change a document at the same time. Hence, it may
have rather strange interactions with normal file system queries.

My question was regarding the man page description
"This works on Unix, MacOS X and Windows (except very old releases)."
but I could not reproduce it on Windows.

All files in my examples are from server backups and are real world
examples for my intended project.

The current situation is, that there are many cases, where Tcl fails (in
sense of runtime errors) unless you catch all these situations.
The reason is an "interpretation" of special characters in filenames,
but in my project I have to handle the files "as they are" and therefore
Tcl may not the right tool if I don't find a reliable solution.
E.g. the tilde expansion only makes sense in a user specific environment
but not on a server where the files of thousands of users must be
handled independently.

In the meantime I've investigated the problem more deeply and igor.g
pointed me to the [subst] solution, that works in all my cases until
now.

The possibility to disable any "interpretation" by an option (e.g.
-nosubst) could solve this problem and would not break any
compatibility.
IMHO: In future versions (>=9) this feature should be removed or
disabled by default.

THX
--
Gerhard Reithofer
Tech-EDV Support Forum - http://support.tech-edv.co.at
.



Relevant Pages

  • Re: Tilde expansion on (Windows)files?
    ... working on a storage optimization system I realized, ... that a tilde in a filename makes problems: ... If it works on Windows, why doesn't it find the file? ... E.g. the tilde expansion only makes sense in a user specific environment ...
    (comp.lang.tcl)
  • Tilde expansion on (Windows)files?
    ... working on a storage optimization system I realized, ... What does this mean, which filename is searched? ... If it works on Windows, why doesn't it find the file? ... How can this file be handled in Tcl? ...
    (comp.lang.tcl)
  • Re: Tilde expansion on (Windows)files?
    ... working on a storage optimization system I realized, that a tilde in a filename makes problems: ... What does this mean, which filename is searched? ... If it works on Windows, why doesn't it find the file? ... contains information about which user has the file open, to prevent multiple users from attempting to change a document at the same time. ...
    (comp.lang.tcl)
  • Re: Tilde expansion on (Windows)files?
    ... working on a storage optimization system I realized, ... that a tilde in a filename makes problems: ... If it works on Windows, why doesn't it find the file? ...
    (comp.lang.tcl)
  • Re: Tilde expansion on (Windows)files?
    ... Tcl 8.5.4, Windows XP - test: ... What does this mean, which filename is searched? ... If it works on Windows, why doesn't it find the file? ... 'file normalize' interaction with tilde ...
    (comp.lang.tcl)