Filename.st
branchjv
changeset 17795 569eec7576f1
parent 17780 b6e42c92eba0
child 17800 142da80d8c82
--- a/Filename.st	Sun Aug 01 12:11:07 2010 +0100
+++ b/Filename.st	Tue Aug 10 09:55:15 2010 +0100
@@ -274,6 +274,32 @@
 
 !Filename class methodsFor:'instance creation'!
 
+applicationDataDirectoryFor:appName
+    "return the directory, where user-and-application-specific private files are to be
+     located (ini-files, preferences etc.).
+     Under windows, something like 'C:\Users\Administrator\AppData\Roaming\<appName>'
+     is returned, under unix, we use ~/.<appName> (but see details in UnixOS).
+     If the directory does not exist, it is created"
+
+    |s dir|
+
+    s := OperatingSystem getApplicationDataDirectoryFor:appName.
+    s isNil ifTrue:[
+        ^ self homeDirectory
+    ].
+    dir := self named:s.
+    dir exists ifFalse:[
+        dir makeDirectory
+    ].
+    ^ dir
+
+    "                    
+     Filename applicationDataDirectoryFor:'expecco'        
+    "
+
+    "Created: / 29-07-2010 / 12:05:35 / sr"
+!
+
 currentDirectory
     "return a filename for the current directory"
 
@@ -2773,19 +2799,14 @@
      (Notice, that a rename is tried first, in case of non-cross device move)"
 
     [self renameTo:newName] 
-        on:(OperatingSystem errorSignal) 
+        on:(OSErrorHolder inappropriateReferentSignal) 
         do:[:ex |
-            ex signal == OperatingSystem fileNotFoundErrorSignal ifTrue:[
-                ex reject
-            ].
-            ex signal == OperatingSystem accessDeniedErrorSignal ifTrue:[
-                ex reject
-            ].
-
+            "handle renames accross device boundaries (Unix. cross device link)"
             self isDirectory ifTrue:[
                 self recursiveMoveDirectoryTo:newName.
             ] ifFalse:[
-                self moveFileTo:newName.
+                self copyTo:newName.
+                self remove.
             ].
         ].
 
@@ -2813,7 +2834,7 @@
 recursiveCopyTo:destination
     "if I represent a regular file, copy it.
      Otherwise, copy the directory and recursively
-     and recursively all of its subfiles/subdirectories.
+     all of its subfiles/subdirectories.
      Raises an exception if not successful."
 
     |ok d|
@@ -2839,8 +2860,9 @@
         self recursiveCopyWithoutOSCommandTo:destination
     ].
 
-    "Created: / 5.5.1999 / 13:35:01 / cg"
-    "Modified: / 31.5.1999 / 13:11:34 / cg"
+    "Created: / 05-05-1999 / 13:35:01 / cg"
+    "Modified: / 31-05-1999 / 13:11:34 / cg"
+    "Modified: / 29-07-2010 / 12:41:06 / sr"
 !
 
 recursiveCopyWithoutOSCommandTo:destination
@@ -3142,7 +3164,9 @@
         self exists ifFalse:[
             ^ self fileNotFoundError:self
         ].
-        ^ self accessDeniedError:newName asFilename.
+        (OperatingSystem errorHolderForNumber:errno) 
+            parameter:newName asFilename;
+            reportError.
     ].
 
     "
@@ -5775,15 +5799,15 @@
 !Filename class methodsFor:'documentation'!
 
 version
-    ^ '$Id: Filename.st 10544 2010-07-12 16:20:36Z vranyj1 $'
+    ^ '$Id: Filename.st 10564 2010-08-10 08:55:15Z vranyj1 $'
 !
 
 version_CVS
-    ^ 'Header: /cvs/stx/stx/libbasic/Filename.st,v 1.351 2010/05/07 12:06:04 cg Exp '
+    ^ 'Header: /cvs/stx/stx/libbasic/Filename.st,v 1.358 2010/07/29 10:39:38 sr Exp '
 !
 
 version_SVN
-    ^ '$Id: Filename.st 10544 2010-07-12 16:20:36Z vranyj1 $'
+    ^ '$Id: Filename.st 10564 2010-08-10 08:55:15Z vranyj1 $'
 ! !
 
 Filename initialize!
@@ -5792,3 +5816,4 @@
 
 
 
+