Suppose you want to create a directory tree at once. Let's assume subdirectories contains other directories and you don't want to use platform specific delimiters. We can do it in Pharo using the almighty #inject:into: and the FileSystem API.
1 2 3 4 5 6 7 8 9 10 11 12 | | rootPath | rootPath := Path / FileSystem disk store currentDisk / 'App1' . #( #( 'Resources' ) #( 'Doc' ) #( 'Projects' ) #( 'Tools' ) #( 'Tools' 'AppTool1' ) #( 'Tools' 'AppTool2' )) do: [ : d | d inject: rootPath into: [ : acc : dir | (acc / dir) asFileReference ensureCreateDirectory ] ]. |
Hope you liked it
0 comentarios:
Publicar un comentario