[Pharo-project] Moving a file
Neither the Squeak file system support, nor FS seem to contain logic to move a file, like Unix's mv command. This seems like a basic piece of functionality. Why is it missing? Thanks. Sean -- View this message in context: http://forum.world.st/Moving-a-file-tp3983916p3983916.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
Possible answers: (1) Squeak's file system leaves a lot to be desired - give us time :) (2) It's not really missing, use OSProcess and mv. (3) FileDirectory contains some copy and delete functionality that could be combined (1) is probably the most truthful answer; (3) the most helpful. OSProcess "really works." When I last checked, it did not work on Windows; consider ProcessWrapper on windows. HTH Bill ________________________________________ From: pharo-project-bounces@lists.gforge.inria.fr [pharo-project-bounces@lists.gforge.inria.fr] on behalf of Sean P. DeNigris [sean@clipperadams.com] Sent: Wednesday, November 02, 2011 9:09 PM To: pharo-project@lists.gforge.inria.fr Subject: [Pharo-project] Moving a file Neither the Squeak file system support, nor FS seem to contain logic to move a file, like Unix's mv command. This seems like a basic piece of functionality. Why is it missing? Thanks. Sean -- View this message in context: http://forum.world.st/Moving-a-file-tp3983916p3983916.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
Thanks, Bill. Schwab,Wilhelm K wrote:
(1) Squeak's file system leaves a lot to be desired - give us time :)
I didn't mean that as a dig against Squeak, just as a shorthand for "the file system that traditionally has been included with Squeak" Schwab,Wilhelm K wrote:
(2) It's not really missing, use OSProcess and mv.
Yes, I think this is the best option for now; but my inquiry was also a nudge to add this to the FS API ;-) Schwab,Wilhelm K wrote:
(3) FileDirectory contains some copy and delete functionality that could be combined
I want mv because of efficiency - cp-ing & then deleting 3.5gb takes what feels like about 30 seconds, where an mv feels instantaneous. Sean -- View this message in context: http://forum.world.st/Moving-a-file-tp3983916p3984022.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
Sean, A couple of examples that might be helpful: (1) ping somebody and get the output: ^( PipeableOSProcess command:'ping ', host, ' -c 4' ) output. (2) from the selector name, I'm guessing that Dave was kind enough to send me this example in the days when I was completely (vs. now partially) clueless about the correct use of OSProcess: tryDave | gp | gp := PipeableOSProcess command:'gnuplot'. gp setNonBlockingOutput. gp exec:'set output ""'; exec:'set terminal png'; exec:'plot sin(x)'. (Delay forMilliseconds: 1000) wait. "allow gnuplot to send data" gp upToEnd inspect. "all available stdout data" gp errorUpToEnd inspect. "all available stderr data" gp close. FWIW, it appears that I use exclusively PipeableOSProcess. Note that you might need to send #closePipes. Sadly, my comments don't say *why* I added it (distinct from above examples), but since I'm only now finding them, the addition must of fixed the problem I was having. Searching the archives will likely turn up something with Dave explaining how and when to use it. Good luck. Bill ________________________________________ From: pharo-project-bounces@lists.gforge.inria.fr [pharo-project-bounces@lists.gforge.inria.fr] on behalf of Sean P. DeNigris [sean@clipperadams.com] Sent: Wednesday, November 02, 2011 9:58 PM To: pharo-project@lists.gforge.inria.fr Subject: Re: [Pharo-project] Moving a file Thanks, Bill. Schwab,Wilhelm K wrote:
(1) Squeak's file system leaves a lot to be desired - give us time :)
I didn't mean that as a dig against Squeak, just as a shorthand for "the file system that traditionally has been included with Squeak" Schwab,Wilhelm K wrote:
(2) It's not really missing, use OSProcess and mv.
Yes, I think this is the best option for now; but my inquiry was also a nudge to add this to the FS API ;-) Schwab,Wilhelm K wrote:
(3) FileDirectory contains some copy and delete functionality that could be combined
I want mv because of efficiency - cp-ing & then deleting 3.5gb takes what feels like about 30 seconds, where an mv feels instantaneous. Sean -- View this message in context: http://forum.world.st/Moving-a-file-tp3983916p3984022.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
Make that "must have" Clearly (past) time to get some sleep. With that, happy Smalltalking to all, and good night :) ________________________________________ From: pharo-project-bounces@lists.gforge.inria.fr [pharo-project-bounces@lists.gforge.inria.fr] on behalf of Schwab,Wilhelm K [bschwab@anest.ufl.edu] Sent: Wednesday, November 02, 2011 11:46 PM To: Pharo-project@lists.gforge.inria.fr Subject: Re: [Pharo-project] Moving a file Sean, A couple of examples that might be helpful: (1) ping somebody and get the output: ^( PipeableOSProcess command:'ping ', host, ' -c 4' ) output. (2) from the selector name, I'm guessing that Dave was kind enough to send me this example in the days when I was completely (vs. now partially) clueless about the correct use of OSProcess: tryDave | gp | gp := PipeableOSProcess command:'gnuplot'. gp setNonBlockingOutput. gp exec:'set output ""'; exec:'set terminal png'; exec:'plot sin(x)'. (Delay forMilliseconds: 1000) wait. "allow gnuplot to send data" gp upToEnd inspect. "all available stdout data" gp errorUpToEnd inspect. "all available stderr data" gp close. FWIW, it appears that I use exclusively PipeableOSProcess. Note that you might need to send #closePipes. Sadly, my comments don't say *why* I added it (distinct from above examples), but since I'm only now finding them, the addition must of fixed the problem I was having. Searching the archives will likely turn up something with Dave explaining how and when to use it. Good luck. Bill ________________________________________ From: pharo-project-bounces@lists.gforge.inria.fr [pharo-project-bounces@lists.gforge.inria.fr] on behalf of Sean P. DeNigris [sean@clipperadams.com] Sent: Wednesday, November 02, 2011 9:58 PM To: pharo-project@lists.gforge.inria.fr Subject: Re: [Pharo-project] Moving a file Thanks, Bill. Schwab,Wilhelm K wrote:
(1) Squeak's file system leaves a lot to be desired - give us time :)
I didn't mean that as a dig against Squeak, just as a shorthand for "the file system that traditionally has been included with Squeak" Schwab,Wilhelm K wrote:
(2) It's not really missing, use OSProcess and mv.
Yes, I think this is the best option for now; but my inquiry was also a nudge to add this to the FS API ;-) Schwab,Wilhelm K wrote:
(3) FileDirectory contains some copy and delete functionality that could be combined
I want mv because of efficiency - cp-ing & then deleting 3.5gb takes what feels like about 30 seconds, where an mv feels instantaneous. Sean -- View this message in context: http://forum.world.st/Moving-a-file-tp3983916p3984022.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
we should add it. Stef On Nov 3, 2011, at 2:09 AM, Sean P. DeNigris wrote:
Neither the Squeak file system support, nor FS seem to contain logic to move a file, like Unix's mv command. This seems like a basic piece of functionality. Why is it missing?
Thanks. Sean
-- View this message in context: http://forum.world.st/Moving-a-file-tp3983916p3983916.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
I found FSReference>>renameAs:, which doesn't work (there's already an issue filed), but seems to provide something similar. So maybe we just need a moveTo: that forwards to renameAs:, or v.v. I'll know more if I can get renameAs: working. Trying now... -- View this message in context: http://forum.world.st/Moving-a-file-tp3983916p3985924.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
I wrote a partial fix (move and rename now work for disk filesystems on my mac) and uploaded it to sqs/fs. Here's the package comment for FS-Core-SeanDeNigris.16 (the other affected package is FS-Disk-SeanDeNigris.4):
* Partially fixed FSReference>>renameAs:. It now works for disk filesystems. * added FSReference>>moveTo:
WARNING: this introduces a slight change into the API. #renameAs: now is a shortcut to simply change a file's name while staying in the same parent directory. As such, it now takes a string (used to take a path or string). What renameAs: used to do (move to an arbitrary other location) is now done by #moveTo: which takes a target reference.
I tested by hand, but at minimum, it's less broken than before :) It doesn't touch any other parts of FS, so shouldn't have broken anything else. Sean -- View this message in context: http://forum.world.st/Moving-a-file-tp3983916p3986244.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
Hi Sean, I've tested it on my mac it seems to work fine. Have you tested it on Linux? If so, May I update the ConfigurationOfFilesytem to include your fix? Francois On 03/11/11 08:09, Sean P. DeNigris wrote:
I wrote a partial fix (move and rename now work for disk filesystems on my mac) and uploaded it to sqs/fs. Here's the package comment for FS-Core-SeanDeNigris.16 (the other affected package is FS-Disk-SeanDeNigris.4):
* Partially fixed FSReference>>renameAs:. It now works for disk filesystems. * added FSReference>>moveTo:
WARNING: this introduces a slight change into the API. #renameAs: now is a shortcut to simply change a file's name while staying in the same parent directory. As such, it now takes a string (used to take a path or string). What renameAs: used to do (move to an arbitrary other location) is now done by #moveTo: which takes a target reference.
I tested by hand, but at minimum, it's less broken than before :) It doesn't touch any other parts of FS, so shouldn't have broken anything else.
Sean
-- View this message in context: http://forum.world.st/Moving-a-file-tp3983916p3986244.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
-- http://tulipemoutarde.be BE: +32 (0)65 709 131 CA: +1 778 558 3225
fstephany wrote:
I've tested it on my mac it seems to work fine. Have you tested it on Linux? If so, May I update the ConfigurationOfFilesytem to include your fix?
I only tested it on Mac. Feel free to include it as you see fit. Sean -- View this message in context: http://forum.world.st/Moving-a-file-tp3983916p4088990.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
On an other side, wouldnt be handy if renameAs: returns a new FSReference to the newly created file (or update the location of the current one)? On 03/11/11 08:09, Sean P. DeNigris wrote:
I wrote a partial fix (move and rename now work for disk filesystems on my mac) and uploaded it to sqs/fs. Here's the package comment for FS-Core-SeanDeNigris.16 (the other affected package is FS-Disk-SeanDeNigris.4):
* Partially fixed FSReference>>renameAs:. It now works for disk filesystems. * added FSReference>>moveTo:
WARNING: this introduces a slight change into the API. #renameAs: now is a shortcut to simply change a file's name while staying in the same parent directory. As such, it now takes a string (used to take a path or string). What renameAs: used to do (move to an arbitrary other location) is now done by #moveTo: which takes a target reference.
I tested by hand, but at minimum, it's less broken than before :) It doesn't touch any other parts of FS, so shouldn't have broken anything else.
Sean
-- View this message in context: http://forum.world.st/Moving-a-file-tp3983916p3986244.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
-- http://tulipemoutarde.be BE: +32 (0)65 709 131 CA: +1 778 558 3225
Good. Did you write some tests? On Nov 3, 2011, at 4:09 PM, Sean P. DeNigris wrote:
I wrote a partial fix (move and rename now work for disk filesystems on my mac) and uploaded it to sqs/fs. Here's the package comment for FS-Core-SeanDeNigris.16 (the other affected package is FS-Disk-SeanDeNigris.4):
* Partially fixed FSReference>>renameAs:. It now works for disk filesystems. * added FSReference>>moveTo:
WARNING: this introduces a slight change into the API. #renameAs: now is a shortcut to simply change a file's name while staying in the same parent directory. As such, it now takes a string (used to take a path or string). What renameAs: used to do (move to an arbitrary other location) is now done by #moveTo: which takes a target reference.
I tested by hand, but at minimum, it's less broken than before :) It doesn't touch any other parts of FS, so shouldn't have broken anything else.
Sean
-- View this message in context: http://forum.world.st/Moving-a-file-tp3983916p3986244.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
Stéphane Ducasse wrote
Did you write some tests?
Not yet. -- View this message in context: http://forum.world.st/Moving-a-file-tp3983916p4092117.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
participants (4)
-
Francois Stephany -
Schwab,Wilhelm K -
Sean P. DeNigris -
Stéphane Ducasse