f



[Tcl] file copy does not "touch" file. Why?

In a situation, when both source and destination files exist, file copy (with
-force of course) does not update the last modification time of the
destination file. This "feature" has a strong impact on cooperation with
'make'.

Is that really intended? I have to do 'touch' externally to make it correct.
The external "cp" command on unix does touch the destination file.

-- 
//  _    ___         Michal "Sektor" Malecki <sektor(whirl)kis.p.lodz.pl>
\\ L_ |/ `|  /^\ ,()                         <ethourhs(O)gmail.com>
// \_ |\  \/ \_/ /\ C++ bez cholesterolu: http://www.intercon.pl/~sektor/cbx
"I am allergic to Java because programming in Java reminds me casting spells"
0
ethouris1 (65)
3/21/2006 10:49:37 AM
comp.lang.tcl 23429 articles. 2 followers. Post Follow

2 Replies
902 Views

Similar Articles

[PageSpeed] 8

Sektor van Skijlen wrote:
> In a situation, when both source and destination files exist, file copy (with
> -force of course) does not update the last modification time of the
> destination file. This "feature" has a strong impact on cooperation with
> 'make'.

It's that way because it makes it easier to do archival backups. If you
want the mtime of the destination to be *now*, try this:

  proc creatingFileCopy {source destination} {
     file copy $source $destination
     file mtime $destination [clock seconds]
  }

You might argue that there should be an option to tell [file copy] to
not copy the metadata. I'd probably not argue the matter, but currently
the metadata copy is done, since it's part of producing a "copy".

Donal.
0
3/21/2006 11:28:55 AM
Dnia Tue, 21 Mar 2006 11:28:55 +0000, Donal K. Fellows skrobie:
> Sektor van Skijlen wrote:
> > In a situation, when both source and destination files exist, file copy (with
> > -force of course) does not update the last modification time of the
> > destination file. This "feature" has a strong impact on cooperation with
> > 'make'.

> It's that way because it makes it easier to do archival backups. If you
> want the mtime of the destination to be *now*, try this:

>   proc creatingFileCopy {source destination} {
>      file copy $source $destination
>      file mtime $destination [clock seconds]
>   }

> You might argue that there should be an option to tell [file copy] to
> not copy the metadata. I'd probably not argue the matter, but currently
> the metadata copy is done, since it's part of producing a "copy".

I might argue that there should be an option to file copy:

% file copy -force -mtime $source $target

And it's fine. In particular, works as unix cp command.

-- 
//  _    ___         Michal "Sektor" Malecki <sektor(whirl)kis.p.lodz.pl>
\\ L_ |/ `|  /^\ ,()                         <ethourhs(O)gmail.com>
// \_ |\  \/ \_/ /\ C++ bez cholesterolu: http://www.intercon.pl/~sektor/cbx
"I am allergic to Java because programming in Java reminds me casting spells"
0
ethouris1 (65)
3/21/2006 3:04:50 PM
Reply:

Similar Artilces:

"no such file or directory" when executing tcl file
Hi, new to TCL and hitting a road bump right out the gate. I just installed ActiveTcl 8.5 on my Windows XP SP2 machine. I made the following script and saved it as test.tcl: #!/usr/local/bin/tclsh puts stdout {Hello, Patrick!} When in the TCL command prompt, I type test.tcl and it gives me the error "couldn't execute ".\test.tcl": no such file or directory". I am in the correct directory so I'm pretty lost as to why it is saying this. Here are my exact steps: <open command prompt> H:\workspaces\tcl>tclsh85 % dir Volume in drive H is Data Volume Serial Number is 828C-6076 Directory of H:\workspaces\tcl 01/12/2009 05:23 PM <DIR> . 01/12/2009 05:23 PM <DIR> .. 01/12/2009 05:37 PM 31 test.tcl 1 File(s) 31 bytes 2 Dir(s) 41,173,749,760 bytes free % test.tcl couldn't execute ".\test.tcl": no such file or directory If someone could help fill in the blanks here, I'd appreciate it. Apparently I'm overlooking something obvious. Thanks, Patrick On Jan 13, 12:43=A0am, "Patrick H." <patri...@gmail.com> wrote: > Hi, new to TCL and hitting a road bump right out the gate. I just > installed ActiveTcl 8.5 on my Windows XP SP2 machine. I made the > following script and saved it as test.tcl: > > #!/usr/local/bin/tclsh > puts stdout {Hello, Patrick!} > > When in the TCL command prompt, I type...

Using "source" vs "package require" for Tcl application files
I would like to divide my Tcl application into separate files. Should I generally use "source" to combine the files, or should I use the package mechanism (package provide, package require, etc.)? What is the generally accepted practice? Thanks, Gregg On 30 dec, 01:04, GB <g...@invalid.invalid> wrote: > I would like to divide my Tcl application into separate files. Should I > generally use "source" to combine the files, or should I use the package > mechanism (package provide, package require, etc.)? > > What is the generally accepted practice? > > Thanks, > > Gregg IMHO use [source]. My reasoning: - The package mechanism is meant for getting access to general-purpose libraries, installed directly under the Tcl installation. - You talk of source files for your own application. So I would expect these files to reside in a directory containing that application. Then [source] is easier to use - and you guarantee that you get the source files from your application (otherwise a random package with the same name from the installation could interfer, if you are not careful with the library path) - Using [source] also makes it clear that these files are meant for your application only, not for more general purposes. Regards, Arjen Arjen Markus wrote: > On 30 dec, 01:04, GB <g...@invalid.invalid> wrote: >> I would like to divide my Tcl application into separate files. Should I >> gen...

How to convert a ".p" file to ".m" file
I got a algorithm package. But the matlab file is in p-file. How can I convert these file to m-file so that I can read the source code of the algorithm. Does anyone can help me thanks tinyloop wrote: > > > I got a algorithm package. But the matlab file is in p-file. How > can > I convert these file to m-file so that I can read the source code > of > the algorithm. > Does anyone can help me > thanks Cannot be done and should not be tried / per tinyloop <fcen@ee.cuhk.edu.hk> wrote: > I got a algorithm package. But the matlab file is in p-file. How > can...

is there definition of "binary file" or "text file"
even so called "text file", acturally it's also stored in the binary format. niy38@hotmail.com (Niy) writes: > even so called "text file", acturally it's also stored in > the binary format. There isn't a difference on unix. Unix sees a file as simply a sequence of bytes, which it does not try to interpret. Interpretation of file formats is done at the application level. For example, a database program would expect a certain format, a text editor another format, but the standard I/O routines just deal with streams of bytes. What's the issue you...

why construct file with "", the path of the file return "/"? 364127
l am a little puzzled, why the file's behavior like this: File fl = new File("","1.txt"); System.out.println(fl.getName()); System.out.println(fl.getParent()); System.out.println(fl.getPath()); System.out.println(fl.getAbsolutePath()); try { System.out.println(fl.getCanonicalPath()); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } ...

Re: CONVERTING a ".sas" file into ".dat" file
hi ... just one suggestion (addition) to the code put _all_; writes values preceded by the variable names, plus the SAS automatic variables data _null_; set sashelp.class (obs=2); put _all_; run; Name=Alfred Sex=M Age=14 Height=69 Weight=112.5 _ERROR_=0 _N_=1 Name=Alice Sex=F Age=13 Height=56.5 Weight=84 _ERROR_=0 _N_=2 make one addition ... data _null_; set sashelp.class (obs=2); put (_all_) (:); run; Alfred M 14.0 69.0 112.5 Alice F 13.0 56.5 84.0 and another idea ... if you want the data aligned in columns ... data _null_; set sashelp.class (obs=2); pu...

Problem with "Skip file types" in "Find Files".
I would like to search for text files based on some texts. And I want to exclude svn file (i.e. *.svn-base). So I add the extension .svn-base in "Skip file types" and expect Matlab "Find Files" GUI to skip the svn files. However, "Find Files" still returns the svn file. I think "Find Files" has problem with this kind of filename, eg. "abc.c.svn-base". Is it treating "c.svn-base" as extension? However, I try out the Matlab function FILEPARTS and it works fine. >> [pathstr, name, ext, versn] = fileparts('abc.c.svn-base') ...

What is a "File URL" as opposed to a "non-file URL"
Hi, Sorry to be thick, but what is a "File URL"? Looking on the web, the closest I got to it was a URL that literally starts with "File:"; is that correct? The reason I ask is that I'm looking at IE Java security settings in my IE browser and it says that "Connect to non-file url codebase" is OK but "File Based" is disabled. As I hope to have the flexibility to use a subset of FTP as the protocol to upload my Applets from VMS I am hoping that "File Based" does mean "file:" and does not pertain to FTP vs HTTP. Does it just mean &...

Re: software "file.txt" to "file.dat"
On 1/1/05 at 2:33 AM, malo@mncn.csic.es (Aurelio F Malo) wrote: >I' d like to ask you if there is a way to transform a "file.txt" >into a "file.dat" format. I am certain there is. But I cannot provide details until you specify the format details of each file. For example, you could have "file.txt" formatted as: a single numeric record per line multiple mixed records per line with records separated by tabs, spaces, commas etc Mathematica Lists The point is neither the extension .txt nor the extension .dat are sufficient to specify the fo...

now do you "link" .tcl files?
Hello, I am trying to accomplish the most basic form of "linking" files, with Tcl, and I am having difficulty. I have 2 .tcl files in the same dir: lib.tcl and prog.tcl, and I want to define a proc in lib.tcl, but use it in prog.tcl. What is the right way to do this? I did manage to accomplish this, by doing source lib.tcl in prog.tcl The problem with this approach, is that depending on where I call tclsh from, I have to change the above line. For example, if I call it from a subdirectory, I have to do: source ..\\prog.tcl So this is certainly not the right way to do linking. In the simplest case of linking, the lib.tcl and prog.tcl are in the same directory, then there should be a way to link them no matter where tclsh is called from. How? (I did RTFM carefully but I can't seem to find this) Mark Mark Mark_Galeck wrote: > Hello, I am trying to accomplish the most basic form of "linking" > files, with Tcl, and I am having difficulty. I have 2 .tcl files in > the same dir: lib.tcl and prog.tcl, and I want to define a proc in > lib.tcl, but use it in prog.tcl. What is the right way to do this? > > I did manage to accomplish this, by doing > > source lib.tcl > > in prog.tcl > > > The problem with this approach, is that depending on where I call > tclsh from, I have to change the above line. For example, if I call > it from a subdirectory, I have to do: > > source ..\\prog.tcl &...

Short file format: "Progra~1" for "Program Files"
Hello all, From my Windows command prompt, I'm trying to run an .exe which requires an argument for CLASSPATH, along the lines, <%> Foo.exe -CLASSPATH="C:\Program Files\AppFolder\a.jar....." When the length of CLASSPATH's value is quite large, the .exe doesnt work the way it should. To truncate the CLASSPATH length I tried "C:\Progra~1" for "C:\Program Files". It seems to work fine. This exe needs to run on the end-user's PC. My question is, how reliable is it to use "Progra~1" for "Program Files". If the end-user installs some software which changes "Program Files" from Progra~1 to Progra~2, would I run into trouble. Has anyone run into this situation before? Thanks for your time, Prabh Prabh wrote: > This exe needs to run on the end-user's PC. > My question is, how reliable is it to use "Progra~1" for "Program > Files". Not at all. > If the end-user installs some software which changes "Program Files" > from Progra~1 to Progra~2, would I run into trouble. Yes. In fact, hard-coding C:\Program Files is wrong. > Has anyone run into this situation before? Yes, though I've not needed to use a short file name in a long time. You should call SHGetFolderPath or similar, followed by GetShortPathName. Note that a file or directory might not have a short name, in which case you're probably stuck. ...

File.new("file.ext", "w").write data
Consider... File.new("file.ext", "w").write data Is this safe? When will the file be closed? For IO it's said: "I/O streams are automatically closed when they are claimed by the garbage collector." Is this true for files as well, (File is a subclass of IO)? I know you can do... File.open("file.ext", "w"){|f| f.write data} ...., but the first one is shorter and better readable. gegroet, Erik V. Erik, The file handle will indeed stay open until the File instance is GC'd. The block-passing version is a few extra characters, but...

can the command "dir" display the "file verison" of a file?
I would like to use DOS command to display the "file verison" of a file, and I have checked with the "help", it seems "dir" does not have this parameter. Can someone help me? Thanks a lot <mander.lala@gmail.com> wrote: >I would like to use DOS command to display the "file verison" of a > file, and I have checked with the "help", it seems "dir" does not have > this parameter. What "file version" is that? DOS-files doesn't have any such thing. If you mean the build-version in a PE/Win execu...

Fast alternatives to "File" and "IO" for large numbers of files ?
People, I have script that does: - statistical processing from data in 50x32x20 (32,000) large input files - writes a small text file (22 lines with one or more columns of numbers) for each input file - read all small files back in again for final processing. Profiling shows that IO is taking up more than 60% of the time - short of making fewer, larger files for the data (which is inconvenient for random viewing/ processing of individual results) are there other alternatives to using the "File" and "IO" classes that would be faster? Thanks, Phil. ...

files "." and ".." from readdir()
Will readdir always return "." and ".." as the _first_ two entries returned if the filesystem has them? I'm just curious if it testing for them can be skipped after the first two have been tested. I've always written my loops around readdir with the tests applied in every case. -- |WARNING: Due to extreme spam, googlegroups.com is blocked. Due to ignorance | | by the abuse department, bellsouth.net is blocked. If you post to | | Usenet from these places, find another Usenet provider ASAP. | | Phil Howard KA9WGN (email for humans: first ...

Re: File specification and "file" statement"
You had better do a %put of the exact, entire line that you are attempting to generate. I'm better that you macro variables contain some embedded blanks, quotes, or other special characters that are tripping you up. Also, are two consecutive slashes legal in a *nix path specification? Anyway, add this right before your data step and see what it prints: %put file "/export/samfs-bcf/rcf-12/mkhan//Create_account_&uscid..&rundate..txt"; ----- Original Message ----- From: "sasdummies" <khanatusc@GMAIL.COM> To: <SAS-L@LISTSERV.UGA.EDU> Sent: Monday, O...

problem on startup: File error: "Cannot open load file", "xfonts"
Hi everybody I just installed the newest emacs testing as emacs package. after starting it with emacs --debug-init I get the error Debugger entered--Lisp error: (file-error "Cannot open load file" "xfonts") require(xfonts) byte-code("��!������@��!��!A��B\"� B��B\"�@��B\"A@*�A�B��!�C���\"��!�FBF��!���\"��!��!I�VH�V��!��!�K%N�!!R�#\"\"\"\"\"S\"!!�\"!!\"!\" �=��Q �=����# �=��Q��\n� � !� ! �\f!\f�\f \"��\f #� a.s.o. The require(xfonts) is in the .gnu-e...

make "File name" default when searching in an "open file" dialogue ?
With Snow Leopard, I have noticed that if, in a file selection dialogue, I want to use the search feature, as I start typing in the search box, the dialogue changes to a search dialogue with a default set to "contents". Anyone know if there is a way to have it default to "File name" ? I find it annoying to have to switch from typing, move mouse to click on the "file name" button, then click back into the input field to finish the seach term. I know this isn't a major issue, but if there were a way to get it to use "file name" by default...

File::Copy giving "Bad File Descriptor" from sysread
I'm modifying a CMS modperl app (WebGUI) and am getting "Bad File Descriptor" from a call to "copy" from the File::Copy module. My setup- perl v5.8.2, OpenBSD OpenBSD 3.5, Apache/1.3.29 with mod_perl/1.27, mysql 4.0.18 The problem seems to be with copying ANY file from within the app- but if I run "perl -Mfile::Copy -de 1" I can copy the same files using "copy" just fine. To debug, I created a simple small text file: echo foo > /tmp/a chmod a+r /tmp/a And to be sure I knew which part of File::Copy failed, I edited /usr/libdata/perl5/File/Copy....

redirect output of "source a.tcl" to a file
I need to redirect output of TCL commands to a file. I have been able to do it by redirecting the command output using ">". Now I am stuck at source command as it gives me the error % source a.tcl > a.txt wrong # args: should be "source fileName" % How can I run source command and store its output in a file? -- San san <sandeep.gond@gmail.com> wrote: > I need to redirect output of TCL commands to a file. I have been able > to do it by redirecting the command output using ">". Now I am stuck > at source command as it gives me the error > % source a.tcl > a.txt > wrong # args: should be "source fileName" > % > How can I run source command and store its output in a file? Depends on how the "output" is generated inside the script: if it's just the returnvalue of the last command in it, then: set fd [open a.txt w]; puts $fd [source a.tcl]; close $fd if the a.tcl contains "puts" to stdout/stderr, you may replace the "puts" command to do something else. if the a.tcl contains calls to external programs that write directly to stdout/stderr, you'll have to reopen those channels first, but this effect will then remain even after the sourcing. source a.tcl does execute the commands in a.tcl within the same instance of tclsh as where you called "source" from. If you don't want any effects from a.tcl to remain in the curr...

file open "no such file"
I am getting this error when I try to run the code below **************** f = open("~/m", "r") print f.read() **************** **************** :~$ python python/my.py Traceback (most recent call last): File "python/my.py", line 1, in ? f = open("~/m", "r") IOError: [Errno 2] No such file or directory: '~/m' **************** but I have the "m" file in my home/username/ thank you Gary Wessle wrote: > I am getting this error when I try to run the code below > > **************** > f = open("~/m"...

File::Temp: opening the temp. file in "r+" mode? Also "man in the middle"
Hi, I'm working at a CGI-script which would receive a 20 MB big file via HTTP-upload, then change few bytes in it, then calculate an MD5 hash over a region of that file and save that value into the file as well. At the moment I do the first task (change few bytes) like this (the $flash is coming from the CGI.pm's filefield): my ($fh, $filename) = tempfile(DIR => UPLOADDIR); while (sysread $flash, $chunk, KEYSIZE) { $both = $prev . $chunk; if ($both =~ s/$SEARCH/$REPLACE/o) { print $fh $both; undef $prev; } el...

<input type="file" value="path/file.jpeg"> in Firefox
This code: <form action="processScan.php" method="get"> <p> <?php print "Scan name: <input type=\"file\" name=\"tScanFileName\" value= \"{$scanFileName}\"><br>"; addHiddenCarryons(); ?> <input type="submit"> </form> does not render with the value attribute's value as the default text. I.e., then the form renders, I want the string value of $scanFileName already in the input field as the default text. I'm using Firefox 2.0.0.12, PHP 5.2.4 and Apache 1.3...

How to create a file named "\a" and "-a"
Hi !How to create a file named "\a" and "-a"? dolphin wrote: > Hi !How to create a file named "\a" and "-a"? > "touch \\a" nets you "\a" making "-a" filename is harder.. You may have to resort to C code.. Its pretty hard to get the standard tools to ignore what they interpret as switches. On 16 Mar 2007 at 14:36, dolphin wrote: > Hi !How to create a file named "\a" touch '\a' > and "-a"? touch -- -a (assuming GNU touch) -- email: echo t.adllkhsl@iypzavs.hj.br | tr a-gh-pq...

Web resources about - [Tcl] file copy does not "touch" file. Why? - comp.lang.tcl

Resources last updated: 3/13/2016 4:14:38 PM