file copying, etc

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

file copying, etc

kuszi
Hello!

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?*

Thanks
Robert
_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: file copying, etc

Holger Freyther

> On 22 May 2016, at 18:05, Robert Kuszinger <[hidden email]> 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
_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: file copying, etc

Holger Freyther

> On 22 May 2016, at 18:30, Robert Kuszinger <[hidden email]> wrote:
>


>                      Smalltalk system: 'cp ',from,' ',to.
>
> Also simple :)

and unless you control from and to maybe a bit insecure. We have 'withShellEscapes' (e.g. use like '; rm -rf /' withShellEscapes).

holger


_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk