2853 s close. |
2853 s close. |
2854 f moveTo:'./foo' |
2854 f moveTo:'./foo' |
2855 " |
2855 " |
2856 ! |
2856 ! |
2857 |
2857 |
2858 new_recursiveRemoveAll |
|
2859 "Remove all of my subfiles/subdirectories. |
|
2860 Raise an error if not successful. |
|
2861 This one walks down the directory hierarchy, not using any OS |
|
2862 command to do the remove." |
|
2863 |
|
2864 |files toRemove fileToRemove| |
|
2865 |
|
2866 self isDirectory ifFalse:[^ self]. |
|
2867 files := self directoryContentsAsFilenames. |
|
2868 files isEmpty ifTrue:[^ self]. |
|
2869 |
|
2870 toRemove := OrderedCollection new. |
|
2871 toRemove addAll:files. |
|
2872 [ toRemove notEmpty ] whileTrue:[ |
|
2873 fileToRemove := toRemove removeLast. |
|
2874 Error handle:[:ex | |
|
2875 |children| |
|
2876 |
|
2877 fileToRemove isDirectory ifTrue:[ |
|
2878 children := fileToRemove directoryContentsAsFilenames. |
|
2879 children isEmpty ifTrue:[ |
|
2880 fileToRemove remove |
|
2881 ] ifFalse:[ |
|
2882 toRemove add:fileToRemove. |
|
2883 toRemove addAll:children. |
|
2884 ]. |
|
2885 ] ifFalse:[ |
|
2886 ex reject |
|
2887 ]. |
|
2888 ] do:[ |
|
2889 "/ Transcript showCR:('remove: ', fileToRemove pathName). |
|
2890 fileToRemove remove. |
|
2891 ]. |
|
2892 ]. |
|
2893 |
|
2894 " |
|
2895 'foo' asFilename makeDirectory. |
|
2896 'foo/bar' asFilename writeStream close. |
|
2897 'foo' asFilename remove |
|
2898 " |
|
2899 " |
|
2900 'foo' asFilename makeDirectory. |
|
2901 'foo/bar' asFilename writeStream close. |
|
2902 'foo' asFilename recursiveRemove |
|
2903 " |
|
2904 |
|
2905 "Created: / 11-10-2011 / 10:28:09 / cg" |
|
2906 ! |
|
2907 |
|
2908 recursiveCopyTo:destination |
2858 recursiveCopyTo:destination |
2909 "if I represent a regular file, copy it. |
2859 "if I represent a regular file, copy it. |
2910 Otherwise, copy the directory and recursively |
2860 Otherwise, copy the directory and recursively |
2911 all of its subfiles/subdirectories. |
2861 all of its subfiles/subdirectories. |
2912 Raises an exception if not successful." |
2862 Raises an exception if not successful." |
3091 Otherwise, remove the directory and all of its subfiles/subdirectories. |
3042 Otherwise, remove the directory and all of its subfiles/subdirectories. |
3092 Raise an error if not successful. |
3043 Raise an error if not successful. |
3093 This one walks down the directory hierarchy, not using any OS |
3044 This one walks down the directory hierarchy, not using any OS |
3094 command to do the remove." |
3045 command to do the remove." |
3095 |
3046 |
3096 self new_recursiveRemoveAll. |
3047 self recursiveRemoveAll. |
3097 "/ self recursiveRemoveAll. |
|
3098 self remove |
3048 self remove |
3099 |
3049 |
3100 " |
3050 " |
3101 'foo' asFilename makeDirectory. |
3051 'foo' asFilename makeDirectory. |
3102 'foo/bar' asFilename writeStream close. |
3052 'foo/bar' asFilename writeStream close. |
3107 'foo/bar' asFilename writeStream close. |
3057 'foo/bar' asFilename writeStream close. |
3108 'foo' asFilename recursiveRemove |
3058 'foo' asFilename recursiveRemove |
3109 " |
3059 " |
3110 |
3060 |
3111 "Created: / 25-02-1998 / 19:50:40 / cg" |
3061 "Created: / 25-02-1998 / 19:50:40 / cg" |
3112 "Modified: / 11-10-2011 / 10:29:20 / cg" |
3062 "Modified: / 19-01-2012 / 17:18:28 / cg" |
3113 ! |
3063 ! |
3114 |
3064 |
3115 remove |
3065 remove |
3116 "remove the file/directory. |
3066 "remove the file/directory. |
3117 Raises an exception if not successful. |
3067 Raises an exception if not successful. |
5927 ! ! |
5877 ! ! |
5928 |
5878 |
5929 !Filename class methodsFor:'documentation'! |
5879 !Filename class methodsFor:'documentation'! |
5930 |
5880 |
5931 version |
5881 version |
5932 ^ '$Header: /cvs/stx/stx/libbasic/Filename.st,v 1.372 2011/12/25 10:35:01 cg Exp $' |
5882 ^ '$Header: /cvs/stx/stx/libbasic/Filename.st,v 1.373 2012/01/19 16:20:58 cg Exp $' |
5933 ! |
5883 ! |
5934 |
5884 |
5935 version_CVS |
5885 version_CVS |
5936 ^ 'Header: /cvs/stx/stx/libbasic/Filename.st,v 1.372 2011/12/25 10:35:01 cg Exp ' |
5886 ^ 'Header: /cvs/stx/stx/libbasic/Filename.st,v 1.373 2012/01/19 16:20:58 cg Exp ' |
5937 ! |
5887 ! |
5938 |
5888 |
5939 version_SVN |
5889 version_SVN |
5940 ^ '$Id: Filename.st 10761 2012-01-19 11:46:00Z vranyj1 $' |
5890 ^ '$Id: Filename.st 10763 2012-01-22 23:07:15Z vranyj1 $' |
5941 ! ! |
5891 ! ! |
5942 |
5892 |
5943 Filename initialize! |
5893 Filename initialize! |
5944 |
5894 |
5945 |
5895 |
5946 |
5896 |
5947 |
5897 |
|
5898 |