Filename.st
changeset 10663 b95f903be43e
parent 10583 71c4724f0b29
child 10769 5623284ae0a0
equal deleted inserted replaced
10662:865a5649d8d6 10663:b95f903be43e
   290     "
   290     "
   291 
   291 
   292     "Modified: 8.9.1997 / 00:24:15 / cg"
   292     "Modified: 8.9.1997 / 00:24:15 / cg"
   293 !
   293 !
   294 
   294 
   295 currentDirectoryName
       
   296     "return a filename for the current directory"
       
   297 
       
   298     self == Filename ifTrue:[
       
   299         ^ ConcreteClass currentDirectoryName
       
   300     ].
       
   301 
       
   302     "/ fallBack - works on Unix & MSDOS (but not on VMS)
       
   303 
       
   304     ^ '.'
       
   305 
       
   306     "
       
   307      Filename currentDirectoryName    
       
   308     "
       
   309 
       
   310     "Modified: / 8.9.1997 / 00:24:15 / cg"
       
   311     "Created: / 21.10.1998 / 17:49:57 / cg"
       
   312 !
       
   313 
       
   314 defaultDirectory
   295 defaultDirectory
   315     "ST80 compatibility: same as currentDirectory"
   296     "ST80 compatibility: same as currentDirectory"
   316 
   297 
   317     ^ self currentDirectory
   298     ^ self currentDirectory
   318 
   299 
   319     "
   300     "
   320      Filename defaultDirectory 
   301      Filename defaultDirectory 
   321     "
       
   322 !
       
   323 
       
   324 defaultDirectoryName
       
   325     "ST80 compatibility: return the defaultDirectories name (as a string)"
       
   326 
       
   327     ^ self defaultDirectory name
       
   328 
       
   329     "
       
   330      Filename defaultDirectoryName 
       
   331     "
   302     "
   332 !
   303 !
   333 
   304 
   334 desktopDirectory
   305 desktopDirectory
   335     "return your desktop directory.
   306     "return your desktop directory.
   732      If any of the environment variables STX_TMPDIR, ST_TMPDIR,
   703      If any of the environment variables STX_TMPDIR, ST_TMPDIR,
   733      TMPDIR or TEMPDIR is set, its value defines the name, 
   704      TMPDIR or TEMPDIR is set, its value defines the name, 
   734      otherwise, '/tmp' is used. (at least on unix ...).
   705      otherwise, '/tmp' is used. (at least on unix ...).
   735 
   706 
   736      Notice: do not hardcode '/tmp' into your programs - things may be
   707      Notice: do not hardcode '/tmp' into your programs - things may be
   737              different on other OS's. Also, the user may want to set the
   708              different on other operating systems. Also, the user may want to set the
   738              TMPDIR environment variable to have her temp files somewhere else.
   709              TMPDIR environment variable to have her temp files somewhere else."
   739              (especially on SUNOS, the root partition is ALWAYS too small ..."
       
   740 
   710 
   741     |tempDir|
   711     |tempDir|
   742 
   712 
   743     TempDirectory isNil ifTrue:[
   713     TempDirectory isNil ifTrue:[
   744         #('STX_TMPDIR' 'ST_TMPDIR' 'TMPDIR' 'TEMPDIR' 'TEMP' 'TMP') do:[:envVar |
   714         #('STX_TMPDIR' 'ST_TMPDIR' 'TMPDIR' 'TEMPDIR' 'TEMP' 'TMP') do:[:envVar |
   754         ].
   724         ].
   755         tempDir isNil ifTrue:[
   725         tempDir isNil ifTrue:[
   756             tempDir := self named:self defaultTempDirectoryName
   726             tempDir := self named:self defaultTempDirectoryName
   757         ].
   727         ].
   758         TempDirectory := tempDir construct:'stx_tmp'.
   728         TempDirectory := tempDir construct:'stx_tmp'.
   759         TempDirectory makeDirectory.
       
   760     ].
   729     ].
   761 
   730 
   762     "Make sure, that the TempDirectory exists - it might have been removed
   731     "Make sure, that the TempDirectory exists - it might have been removed
   763      by a cleanup (cron) job"
   732      by a cleanup (cron) job.
       
   733      Since it is shared between users, it must be accessable by all users."
   764 
   734 
   765     TempDirectory exists ifFalse:[
   735     TempDirectory exists ifFalse:[
   766         TempDirectory makeDirectory.
   736         TempDirectory 
       
   737             makeDirectory; 
       
   738             addAccessRights:#(readUser readGroup readOthers 
       
   739                               writeUser writeGroup writeOthers
       
   740                               executeUser executeGroup executeOthers
       
   741                               removeOnlyByOwner).
   767     ].
   742     ].
   768     ^ TempDirectory
   743     ^ TempDirectory
   769 
   744 
   770     "
   745     "
   771      Filename tempDirectory           
   746      Filename tempDirectory           
   774      Filename tempDirectory isWritable   
   749      Filename tempDirectory isWritable   
   775      (Filename tempDirectory construct:'foo') makeDirectory   
   750      (Filename tempDirectory construct:'foo') makeDirectory   
   776      (Filename tempDirectory construct:'foo') remove   
   751      (Filename tempDirectory construct:'foo') remove   
   777     "
   752     "
   778 
   753 
   779     "Modified: / 07-09-1995 / 10:48:31 / claus"
       
   780     "Created: / 07-03-1996 / 14:51:18 / cg"
   754     "Created: / 07-03-1996 / 14:51:18 / cg"
   781     "Modified: / 29-08-2006 / 12:57:16 / cg"
   755     "Modified: / 29-08-2006 / 12:57:16 / cg"
   782 ! !
   756 ! !
   783 
   757 
   784 !Filename class methodsFor:'defaults'!
   758 !Filename class methodsFor:'defaults'!
   962      Filename components:'\\idefix\home'     
   936      Filename components:'\\idefix\home'     
   963      Filename components:'\\idefix\home\bar'    
   937      Filename components:'\\idefix\home\bar'    
   964     "
   938     "
   965 
   939 
   966     "Modified: / 24.9.1998 / 19:10:52 / cg"
   940     "Modified: / 24.9.1998 / 19:10:52 / cg"
       
   941 !
       
   942 
       
   943 currentDirectoryName
       
   944     "return a filename for the current directory"
       
   945 
       
   946     self == Filename ifTrue:[
       
   947         ^ ConcreteClass currentDirectoryName
       
   948     ].
       
   949 
       
   950     "/ fallBack - works on Unix & MSDOS (but not on VMS)
       
   951 
       
   952     ^ '.'
       
   953 
       
   954     "
       
   955      Filename currentDirectoryName    
       
   956     "
       
   957 
       
   958     "Modified: / 8.9.1997 / 00:24:15 / cg"
       
   959     "Created: / 21.10.1998 / 17:49:57 / cg"
       
   960 !
       
   961 
       
   962 defaultDirectoryName
       
   963     "ST80 compatibility: return the defaultDirectories name (as a string)"
       
   964 
       
   965     ^ self defaultDirectory name
       
   966 
       
   967     "
       
   968      Filename defaultDirectoryName 
       
   969     "
   967 !
   970 !
   968 
   971 
   969 directorySuffix
   972 directorySuffix
   970     "Return the OS dependent directory suffix string, or nil if there is none.
   973     "Return the OS dependent directory suffix string, or nil if there is none.
   971      The default is nil here, redefined for VMS"
   974      The default is nil here, redefined for VMS"
  5499 ! !
  5502 ! !
  5500 
  5503 
  5501 !Filename class methodsFor:'documentation'!
  5504 !Filename class methodsFor:'documentation'!
  5502 
  5505 
  5503 version
  5506 version
  5504     ^ '$Header: /cvs/stx/stx/libbasic/Filename.st,v 1.316 2007-05-31 15:35:50 stefan Exp $'
  5507     ^ '$Header: /cvs/stx/stx/libbasic/Filename.st,v 1.317 2007-07-16 20:24:35 stefan Exp $'
  5505 ! !
  5508 ! !
  5506 
  5509 
  5507 Filename initialize!
  5510 Filename initialize!