# HG changeset patch # User Claus Gittinger # Date 1048242069 -3600 # Node ID da18863f943bba10c10bced856bf1cd0fa1d9827 # Parent 75dea3234f70f4195f19e71bc850610feb68eaac category changes diff -r 75dea3234f70 -r da18863f943b Filename.st --- a/Filename.st Thu Mar 20 10:35:36 2003 +0100 +++ b/Filename.st Fri Mar 21 11:21:09 2003 +0100 @@ -3314,38 +3314,6 @@ "Modified: / 3.8.1998 / 21:22:30 / cg" ! -isAbsolute - "return true, if the receiver represents an absolute pathname - (in contrast to one relative to the current directory)." - - (nameString startsWith:self class separator) ifTrue:[^ true]. - ^ self isVolumeAbsolute - - " - '/foo/bar' asFilename isAbsolute - '..' asFilename isAbsolute - '..' asAbsoluteFilename isAbsolute - 'source/SBrowser.st' asFilename isAbsolute - " -! - -isDirectory - "return true, if the receiver represents an existing, - readable directories pathname." - - ^ OperatingSystem isDirectory:(self osNameForAccess) - - " - '/foo/bar' asFilename isDirectory - '/tmp' asFilename isDirectory - 'Makefile' asFilename isDirectory - 'c:\' asFilename isDirectory - 'd:\' asFilename isDirectory - " - - "Modified: / 21.9.1998 / 15:53:10 / cg" -! - isExecutable "return true, if such a file exists and is executable (by Unix's definition). For directories, true is returned if the directory can be entered. @@ -3379,13 +3347,6 @@ " ! -isExplicitRelative - "return true, if this name is an explicit relative name - (i.e. starts with './' or '../', to avoid path-prepending)" - - ^ false -! - isHidden "return true, if the receiver represents a hidden file. The definitions of hidden files depends on the OS used; @@ -3396,16 +3357,6 @@ ^ false ! -isImplicit - "return true, if the receiver represents a builtin file. - The definitions of builtin files depends on the OS used; - on UNIX, '.' and '..' are builtin names." - - ^ false - - "Created: 18.9.1997 / 18:04:51 / stefan" -! - isMountPoint:aPathName "return true, if I represent a mount-point. Warning: @@ -3420,32 +3371,6 @@ ^ OperatingSystem isMountPoint:(self name) ! -isNonEmptyDirectory - "return true, if the receiver represents an existing, - readable directories pathname, and the directory is not empty." - - [ - self directoryContentsDo:[:pathString| - ^ true - ]. - ] on:FileStream openErrorSignal do:[ - ^ false - ]. - ^ false. - - " - '/foo/bar' asFilename isNonEmptyDirectory - '/tmp' asFilename isNonEmptyDirectory - '/tmp/empty' asFilename makeDirectory; isNonEmptyDirectory. - '/tmp/empty' asFilename removeDirectory. - 'Makefile' asFilename isNonEmptyDirectory - 'c:\' asFilename isNonEmptyDirectory - 'd:\' asFilename isNonEmptyDirectory - " - - "Modified: / 21.9.1998 / 15:53:10 / cg" -! - isReadable "return true, if such a file exists and is readable." @@ -3458,83 +3383,6 @@ " ! -isRelative - "return true, if this name is interpreted relative to some - directory (opposite of absolute)" - - ^ self isAbsolute not - - " - './foo/bar' asFilename isRelative - '../../foo/bar' asFilename isRelative - '/foo/bar' asFilename isRelative - 'bar' asFilename isRelative - " - - "Modified: 16.1.1997 / 01:19:14 / cg" -! - -isRootDirectory - "return true, if I represent the root directory - (i.e. I have no parentDir)" - - "/ mhmh - should we use: - "/ - "/ parentDir := self construct:'..'. - "/ (parentDir exists - "/ and:[parentDir isDirectory - "/ and:[parentDir id ~= self id]]) ifTrue:[ - "/ ^ false - "/ ]. - "/ ^ true - "/ - - ^ self pathName = Filename rootDirectory pathName - - "Modified: 23.10.1997 / 00:38:35 / cg" -! - -isSpecialFile - "return true, if the receiver represents a socket, named pipe, fifo - or device special file (i.e. anything non regular and non-directory)" - - |t| - - t := self type. - ^ (t ~= #directory and:[t ~~ #regular and:[t ~~ #symbolicLink]]) - - " - '/foo/bar' asFilename isSpecialFile - '/tmp' asFilename isSpecialFile - 'Makefile' asFilename isSpecialFile - 'c:\' asFilename isSpecialFile - 'd:\' asFilename isSpecialFile - '/dev/null' asFilename isSpecialFile - " -! - -isSymbolicLink - "return true, if the file represented by the receiver is a symbolic - link. Notice that not all OS's support symbolic links; those that do - not will always return false." - - ^ OperatingSystem isSymbolicLink:(self osNameForFile) - - " - 'Make.proto' asFilename isSymbolicLink - 'Makefile' asFilename isSymbolicLink - " -! - -isVolumeAbsolute - "return true, if the receiver represents an absolute pathname - on some disk volume (MSDOS only)" - - ^ false - - "Modified: 7.9.1997 / 23:54:33 / cg" -! - isWritable "return true, if such a file exists and is writable." @@ -4053,6 +3901,38 @@ "Modified: 29.2.1996 / 20:21:25 / cg" ! +isAbsolute + "return true, if the receiver represents an absolute pathname + (in contrast to one relative to the current directory)." + + (nameString startsWith:self class separator) ifTrue:[^ true]. + ^ self isVolumeAbsolute + + " + '/foo/bar' asFilename isAbsolute + '..' asFilename isAbsolute + '..' asAbsoluteFilename isAbsolute + 'source/SBrowser.st' asFilename isAbsolute + " +! + +isExplicitRelative + "return true, if this name is an explicit relative name + (i.e. starts with './' or '../', to avoid path-prepending)" + + ^ false +! + +isImplicit + "return true, if the receiver represents a builtin file. + The definitions of builtin files depends on the OS used; + on UNIX, '.' and '..' are builtin names." + + ^ false + + "Created: 18.9.1997 / 18:04:51 / stefan" +! + isParentDirectoryOf:aFilenameOrString "warning: may lead to automounting" @@ -4086,6 +3966,51 @@ " ! +isRelative + "return true, if this name is interpreted relative to some + directory (opposite of absolute)" + + ^ self isAbsolute not + + " + './foo/bar' asFilename isRelative + '../../foo/bar' asFilename isRelative + '/foo/bar' asFilename isRelative + 'bar' asFilename isRelative + " + + "Modified: 16.1.1997 / 01:19:14 / cg" +! + +isRootDirectory + "return true, if I represent the root directory + (i.e. I have no parentDir)" + + "/ mhmh - should we use: + "/ + "/ parentDir := self construct:'..'. + "/ (parentDir exists + "/ and:[parentDir isDirectory + "/ and:[parentDir id ~= self id]]) ifTrue:[ + "/ ^ false + "/ ]. + "/ ^ true + "/ + + ^ self pathName = Filename rootDirectory pathName + + "Modified: 23.10.1997 / 00:38:35 / cg" +! + +isVolumeAbsolute + "return true, if the receiver represents an absolute pathname + on some disk volume (MSDOS only)" + + ^ false + + "Modified: 7.9.1997 / 23:54:33 / cg" +! + localPathName "return the full pathname of the file represented by the receiver, but without any volume information. @@ -4215,6 +4140,83 @@ "Modified: 8.9.1997 / 00:37:33 / cg" ! ! +!Filename methodsFor:'queries-type'! + +isDirectory + "return true, if the receiver represents an existing, + readable directories pathname." + + ^ OperatingSystem isDirectory:(self osNameForAccess) + + " + '/foo/bar' asFilename isDirectory + '/tmp' asFilename isDirectory + 'Makefile' asFilename isDirectory + 'c:\' asFilename isDirectory + 'd:\' asFilename isDirectory + " + + "Modified: / 21.9.1998 / 15:53:10 / cg" +! + +isNonEmptyDirectory + "return true, if the receiver represents an existing, + readable directories pathname, and the directory is not empty." + + [ + self directoryContentsDo:[:pathString| + ^ true + ]. + ] on:FileStream openErrorSignal do:[ + ^ false + ]. + ^ false. + + " + '/foo/bar' asFilename isNonEmptyDirectory + '/tmp' asFilename isNonEmptyDirectory + '/tmp/empty' asFilename makeDirectory; isNonEmptyDirectory. + '/tmp/empty' asFilename removeDirectory. + 'Makefile' asFilename isNonEmptyDirectory + 'c:\' asFilename isNonEmptyDirectory + 'd:\' asFilename isNonEmptyDirectory + " + + "Modified: / 21.9.1998 / 15:53:10 / cg" +! + +isSpecialFile + "return true, if the receiver represents a socket, named pipe, fifo + or device special file (i.e. anything non regular and non-directory)" + + |t| + + t := self type. + ^ (t ~= #directory and:[t ~~ #regular and:[t ~~ #symbolicLink]]) + + " + '/foo/bar' asFilename isSpecialFile + '/tmp' asFilename isSpecialFile + 'Makefile' asFilename isSpecialFile + 'c:\' asFilename isSpecialFile + 'd:\' asFilename isSpecialFile + '/dev/null' asFilename isSpecialFile + " +! + +isSymbolicLink + "return true, if the file represented by the receiver is a symbolic + link. Notice that not all OS's support symbolic links; those that do + not will always return false." + + ^ OperatingSystem isSymbolicLink:(self osNameForFile) + + " + 'Make.proto' asFilename isSymbolicLink + 'Makefile' asFilename isSymbolicLink + " +! ! + !Filename methodsFor:'reading-directories'! directoryContents @@ -4783,7 +4785,7 @@ !Filename class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libbasic/Filename.st,v 1.247 2003-03-18 14:23:20 cg Exp $' + ^ '$Header: /cvs/stx/stx/libbasic/Filename.st,v 1.248 2003-03-21 10:21:09 cg Exp $' ! ! Filename initialize!