help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] file copying, etc


From: Holger Freyther
Subject: Re: [Help-smalltalk] file copying, etc
Date: Sun, 22 May 2016 18:20:28 +0200

> On 22 May 2016, at 18:05, Robert Kuszinger <address@hidden> wrote:
> 
> Hello!

Hi!


> I'm new to this list.
> After years of mixed awk-bash scripting I came to the question:

:)


> 
> "Why don't I script in smalltalk since I'm doing everything else in
> Smalltak?"
> 
> (Pharo, formerly VA)
> 
> After hours of fighting I'm still not able to move/copy file sytem files
> (this is Linux).
> 
> *Are there classes for that?*

The File class binds a lot of the POSIX API. Let's start with "move" here.


st> 'oldName' asFile renameTo: 'newFile'

will move/rename 'oldName' to 'newFile'

For copying I think you would need to do something like:


| outStr |
outStr := 'newFileName' asFile writeStream.
'oldFile' asFile readStream nextPutAllOn: outStr.
outStr close.

A writeStreamDo: might make sense to have the close be called as well. In File 
we have bindings for fsync and fdatasync as well in case you really want to 
control the consistency.


holger


reply via email to

[Prev in Thread] Current Thread [Next in Thread]