UnixFilename.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Thu, 01 Jul 2010 19:21:34 +0100
branchjv
changeset 17772 6e0b3c06c364
parent 17767 a4a32df3aa5e
child 17780 b6e42c92eba0
permissions -rw-r--r--
Method reverted to r10532
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2943
89dee83077bd Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents: 2931
diff changeset
     1
"
89dee83077bd Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents: 2931
diff changeset
     2
 COPYRIGHT (c) 1997 by eXept Software AG
3125
543358373041 care for filenames with blanks when invoking 'file' command
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
     3
	      All Rights Reserved
2943
89dee83077bd Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents: 2931
diff changeset
     4
89dee83077bd Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents: 2931
diff changeset
     5
 This software is furnished under a license and may be used
89dee83077bd Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents: 2931
diff changeset
     6
 only in accordance with the terms of that license and with the
89dee83077bd Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents: 2931
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
89dee83077bd Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents: 2931
diff changeset
     8
 be provided or otherwise made available to, or used by, any
89dee83077bd Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents: 2931
diff changeset
     9
 other person.  No title to or ownership of the software is
89dee83077bd Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents: 2931
diff changeset
    10
 hereby transferred.
89dee83077bd Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents: 2931
diff changeset
    11
"
7939
3a8b75e8f804 catch twoByte string names (assume UTF8)
Claus Gittinger <cg@exept.de>
parents: 3664
diff changeset
    12
"{ Package: 'stx:libbasic' }"
3a8b75e8f804 catch twoByte string names (assume UTF8)
Claus Gittinger <cg@exept.de>
parents: 3664
diff changeset
    13
2907
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
Filename subclass:#UnixFilename
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
	instanceVariableNames:''
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
	classVariableNames:''
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	poolDictionaries:''
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	category:'OS-Unix'
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
!
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
2911
9964e6839a8e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2908
diff changeset
    21
!UnixFilename class methodsFor:'documentation'!
9964e6839a8e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2908
diff changeset
    22
2931
11bcbf8738c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
    23
copyright
11bcbf8738c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
    24
"
11bcbf8738c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
    25
 COPYRIGHT (c) 1997 by eXept Software AG
3125
543358373041 care for filenames with blanks when invoking 'file' command
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
    26
	      All Rights Reserved
2931
11bcbf8738c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
    27
11bcbf8738c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
    28
 This software is furnished under a license and may be used
11bcbf8738c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
    29
 only in accordance with the terms of that license and with the
11bcbf8738c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
11bcbf8738c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
    31
 be provided or otherwise made available to, or used by, any
11bcbf8738c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
    32
 other person.  No title to or ownership of the software is
11bcbf8738c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
    33
 hereby transferred.
11bcbf8738c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
    34
"
11bcbf8738c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
    35
!
11bcbf8738c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
    36
2911
9964e6839a8e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2908
diff changeset
    37
documentation
9964e6839a8e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2908
diff changeset
    38
"
9964e6839a8e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2908
diff changeset
    39
    Filenames in Unix.
9964e6839a8e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2908
diff changeset
    40
"
9964e6839a8e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2908
diff changeset
    41
11318
fc07976462e8 Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents: 9940
diff changeset
    42
!
7939
3a8b75e8f804 catch twoByte string names (assume UTF8)
Claus Gittinger <cg@exept.de>
parents: 3664
diff changeset
    43
11318
fc07976462e8 Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents: 9940
diff changeset
    44
examples
7939
3a8b75e8f804 catch twoByte string names (assume UTF8)
Claus Gittinger <cg@exept.de>
parents: 3664
diff changeset
    45
    "
17767
a4a32df3aa5e merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17761
diff changeset
    46
        (self named:'/tmp/') writeStream close
7939
3a8b75e8f804 catch twoByte string names (assume UTF8)
Claus Gittinger <cg@exept.de>
parents: 3664
diff changeset
    47
    "
3a8b75e8f804 catch twoByte string names (assume UTF8)
Claus Gittinger <cg@exept.de>
parents: 3664
diff changeset
    48
! !
3a8b75e8f804 catch twoByte string names (assume UTF8)
Claus Gittinger <cg@exept.de>
parents: 3664
diff changeset
    49
2907
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
!UnixFilename class methodsFor:'queries'!
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
isBadCharacter:aCharacter
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
    "return true, if aCharacter is unallowed in a filename."
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
    aCharacter == $/ ifTrue:[^ true].
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
    ^ super isBadCharacter:aCharacter
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
    "Created: 8.9.1997 / 00:13:14 / cg"
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
!
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
2908
b3be3629fcb1 vms stuff
Claus Gittinger <cg@exept.de>
parents: 2907
diff changeset
    61
isCaseSensitive
b3be3629fcb1 vms stuff
Claus Gittinger <cg@exept.de>
parents: 2907
diff changeset
    62
    "return true, if filenames are case sensitive.return true, if filenames are case sensitive."
b3be3629fcb1 vms stuff
Claus Gittinger <cg@exept.de>
parents: 2907
diff changeset
    63
b3be3629fcb1 vms stuff
Claus Gittinger <cg@exept.de>
parents: 2907
diff changeset
    64
    ^ true
b3be3629fcb1 vms stuff
Claus Gittinger <cg@exept.de>
parents: 2907
diff changeset
    65
!
b3be3629fcb1 vms stuff
Claus Gittinger <cg@exept.de>
parents: 2907
diff changeset
    66
3171
02ef7b6cc664 Add #nullFilename
Stefan Vogel <sv@exept.de>
parents: 3125
diff changeset
    67
nullFilename
02ef7b6cc664 Add #nullFilename
Stefan Vogel <sv@exept.de>
parents: 3125
diff changeset
    68
    "Return /dev/null"
02ef7b6cc664 Add #nullFilename
Stefan Vogel <sv@exept.de>
parents: 3125
diff changeset
    69
02ef7b6cc664 Add #nullFilename
Stefan Vogel <sv@exept.de>
parents: 3125
diff changeset
    70
    ^ '/dev/null'
02ef7b6cc664 Add #nullFilename
Stefan Vogel <sv@exept.de>
parents: 3125
diff changeset
    71
02ef7b6cc664 Add #nullFilename
Stefan Vogel <sv@exept.de>
parents: 3125
diff changeset
    72
    "
8752
3e7429854c55 comments
Stefan Vogel <sv@exept.de>
parents: 8245
diff changeset
    73
     Filename nullFilename  
3171
02ef7b6cc664 Add #nullFilename
Stefan Vogel <sv@exept.de>
parents: 3125
diff changeset
    74
    "
02ef7b6cc664 Add #nullFilename
Stefan Vogel <sv@exept.de>
parents: 3125
diff changeset
    75
02ef7b6cc664 Add #nullFilename
Stefan Vogel <sv@exept.de>
parents: 3125
diff changeset
    76
    "Modified: / 14.1.1998 / 14:20:55 / stefan"
02ef7b6cc664 Add #nullFilename
Stefan Vogel <sv@exept.de>
parents: 3125
diff changeset
    77
!
02ef7b6cc664 Add #nullFilename
Stefan Vogel <sv@exept.de>
parents: 3125
diff changeset
    78
2908
b3be3629fcb1 vms stuff
Claus Gittinger <cg@exept.de>
parents: 2907
diff changeset
    79
parentDirectoryName
b3be3629fcb1 vms stuff
Claus Gittinger <cg@exept.de>
parents: 2907
diff changeset
    80
    "return the name used for the parent directory.
b3be3629fcb1 vms stuff
Claus Gittinger <cg@exept.de>
parents: 2907
diff changeset
    81
     This is '..' for unix and dos-like systems.
b3be3629fcb1 vms stuff
Claus Gittinger <cg@exept.de>
parents: 2907
diff changeset
    82
     (there may be more in the future."
b3be3629fcb1 vms stuff
Claus Gittinger <cg@exept.de>
parents: 2907
diff changeset
    83
b3be3629fcb1 vms stuff
Claus Gittinger <cg@exept.de>
parents: 2907
diff changeset
    84
    ^ '..'
b3be3629fcb1 vms stuff
Claus Gittinger <cg@exept.de>
parents: 2907
diff changeset
    85
!
b3be3629fcb1 vms stuff
Claus Gittinger <cg@exept.de>
parents: 2907
diff changeset
    86
2907
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
separator
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
    "return the file/directory separator."
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
     ^ $/
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
     "
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
      Filename concreteClass separator  
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
     "
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
    "Created: 8.9.1997 / 00:18:14 / cg"
8245
343908a8a4e1 separatorString / separator
Claus Gittinger <cg@exept.de>
parents: 7939
diff changeset
    97
!
343908a8a4e1 separatorString / separator
Claus Gittinger <cg@exept.de>
parents: 7939
diff changeset
    98
343908a8a4e1 separatorString / separator
Claus Gittinger <cg@exept.de>
parents: 7939
diff changeset
    99
separatorString
343908a8a4e1 separatorString / separator
Claus Gittinger <cg@exept.de>
parents: 7939
diff changeset
   100
    "return the file/directory separator as a string."
343908a8a4e1 separatorString / separator
Claus Gittinger <cg@exept.de>
parents: 7939
diff changeset
   101
343908a8a4e1 separatorString / separator
Claus Gittinger <cg@exept.de>
parents: 7939
diff changeset
   102
    ^ '/'
343908a8a4e1 separatorString / separator
Claus Gittinger <cg@exept.de>
parents: 7939
diff changeset
   103
343908a8a4e1 separatorString / separator
Claus Gittinger <cg@exept.de>
parents: 7939
diff changeset
   104
    "
8752
3e7429854c55 comments
Stefan Vogel <sv@exept.de>
parents: 8245
diff changeset
   105
     Filename separatorString  
8245
343908a8a4e1 separatorString / separator
Claus Gittinger <cg@exept.de>
parents: 7939
diff changeset
   106
    "
2907
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
! !
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
!UnixFilename methodsFor:'file queries'!
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
fileType
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
    "this returns a string describing the type of contents of
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
     the file. This is done using the unix 'file' command,
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
     (which usually is configurable by /etc/magic).
3664
7bcbf8c6c2cf comments;
Claus Gittinger <cg@exept.de>
parents: 3171
diff changeset
   115
     Warning:
7bcbf8c6c2cf comments;
Claus Gittinger <cg@exept.de>
parents: 3171
diff changeset
   116
         Since the returned string differs among systems (and language settings),
7bcbf8c6c2cf comments;
Claus Gittinger <cg@exept.de>
parents: 3171
diff changeset
   117
         it is only useful for user-information; 
7bcbf8c6c2cf comments;
Claus Gittinger <cg@exept.de>
parents: 3171
diff changeset
   118
         NOT as a tag to be used by a program."
2907
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
    |stream typeString|
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
    "/ since executing 'file' takes some time, do the most common
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
    "/ ones are checked first, using the general fileType implementation. 
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
    "/ (also, the file-command is only available on Unix systems.
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
    typeString := super fileType.
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
    typeString ~= 'file' ifTrue:[^ typeString].
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
3125
543358373041 care for filenames with blanks when invoking 'file' command
Claus Gittinger <cg@exept.de>
parents: 2943
diff changeset
   129
    stream := PipeStream readingFrom:('file "' , self pathName , '"').
2907
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
    stream notNil ifTrue:[
3664
7bcbf8c6c2cf comments;
Claus Gittinger <cg@exept.de>
parents: 3171
diff changeset
   131
        typeString := stream contents asString.
7bcbf8c6c2cf comments;
Claus Gittinger <cg@exept.de>
parents: 3171
diff changeset
   132
        stream close.
7bcbf8c6c2cf comments;
Claus Gittinger <cg@exept.de>
parents: 3171
diff changeset
   133
        typeString := typeString copyFrom:(typeString indexOf:$:) + 1.
7bcbf8c6c2cf comments;
Claus Gittinger <cg@exept.de>
parents: 3171
diff changeset
   134
        typeString := typeString withoutSeparators
2907
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
    ].
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
    ^ typeString
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
    "
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
     'Makefile' asFilename fileType 
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
     '.' asFilename fileType     
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
     '/dev/null' asFilename fileType        
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
     'smalltalk.rc' asFilename fileType    
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
     'bitmaps/SBrowser.xbm' asFilename fileType    
3664
7bcbf8c6c2cf comments;
Claus Gittinger <cg@exept.de>
parents: 3171
diff changeset
   144
     '../../libtool/bitmaps/SBrowser.xbm' asFilename fileType    
2907
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
    "
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
3664
7bcbf8c6c2cf comments;
Claus Gittinger <cg@exept.de>
parents: 3171
diff changeset
   147
    "Modified: / 21.7.1998 / 11:26:32 / cg"
2907
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
! !
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
2931
11bcbf8738c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   150
!UnixFilename methodsFor:'queries'!
11bcbf8738c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   151
11bcbf8738c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   152
isExplicitRelative
11bcbf8738c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   153
    "return true, if this name is an explicit relative name
11bcbf8738c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   154
     (i.e. starts with './' or '../', to avoid path-prepending)"
11bcbf8738c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   155
11bcbf8738c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   156
    (nameString startsWith:'./') ifTrue:[
11bcbf8738c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   157
	^ true
11bcbf8738c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   158
    ].
11bcbf8738c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   159
    (nameString startsWith:'../') ifTrue:[
11bcbf8738c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   160
	^ true
11bcbf8738c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   161
    ].
11bcbf8738c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   162
    ^ false
11bcbf8738c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   163
!
11bcbf8738c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   164
11bcbf8738c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   165
isHidden
11bcbf8738c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   166
    "return true, if the receiver represents a hidden file.
11bcbf8738c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   167
     On UNIX, a name starting with a period is considered hidden."
11bcbf8738c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   168
17734
406b1590afe8 Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17711
diff changeset
   169
    |baseName|
406b1590afe8 Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17711
diff changeset
   170
406b1590afe8 Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17711
diff changeset
   171
    baseName := self baseName.
406b1590afe8 Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17711
diff changeset
   172
    ^ ((baseName startsWith:'.') and:[baseName ~= '..'])
2943
89dee83077bd Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents: 2931
diff changeset
   173
!
89dee83077bd Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents: 2931
diff changeset
   174
89dee83077bd Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents: 2931
diff changeset
   175
isImplicit
89dee83077bd Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents: 2931
diff changeset
   176
    "return true, if the receiver represents builtin names such as '.' or '..'.
3664
7bcbf8c6c2cf comments;
Claus Gittinger <cg@exept.de>
parents: 3171
diff changeset
   177
     On UNIX, the current and parent dir names are considered implicit."
2943
89dee83077bd Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents: 2931
diff changeset
   178
89dee83077bd Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents: 2931
diff changeset
   179
    |name|
89dee83077bd Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents: 2931
diff changeset
   180
89dee83077bd Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents: 2931
diff changeset
   181
    name := self baseName.
89dee83077bd Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents: 2931
diff changeset
   182
    ^ name = '.' or:[name = '..'].
89dee83077bd Add #isImplicit to check for builtin dir names such as '.' and '..'.
Stefan Vogel <sv@exept.de>
parents: 2931
diff changeset
   183
3664
7bcbf8c6c2cf comments;
Claus Gittinger <cg@exept.de>
parents: 3171
diff changeset
   184
    "Modified: / 18.9.1997 / 18:03:28 / stefan"
7bcbf8c6c2cf comments;
Claus Gittinger <cg@exept.de>
parents: 3171
diff changeset
   185
    "Modified: / 21.7.1998 / 11:10:42 / cg"
2931
11bcbf8738c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   186
! !
11bcbf8738c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   187
11318
fc07976462e8 Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents: 9940
diff changeset
   188
!UnixFilename methodsFor:'special accessing'!
fc07976462e8 Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents: 9940
diff changeset
   189
fc07976462e8 Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents: 9940
diff changeset
   190
osNameForDirectory
fc07976462e8 Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents: 9940
diff changeset
   191
    "internal - return the OS's name for the receiver to
fc07976462e8 Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents: 9940
diff changeset
   192
     access it as a directory."
fc07976462e8 Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents: 9940
diff changeset
   193
fc07976462e8 Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents: 9940
diff changeset
   194
    ^ self osNameForFile
fc07976462e8 Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents: 9940
diff changeset
   195
!
fc07976462e8 Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents: 9940
diff changeset
   196
fc07976462e8 Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents: 9940
diff changeset
   197
osNameForFile
fc07976462e8 Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents: 9940
diff changeset
   198
    "internal - return the OS's name for the receiver to
fc07976462e8 Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents: 9940
diff changeset
   199
     access it as a file."
fc07976462e8 Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents: 9940
diff changeset
   200
fc07976462e8 Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents: 9940
diff changeset
   201
    nameString bitsPerCharacter < 8 ifTrue:[
fc07976462e8 Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents: 9940
diff changeset
   202
        ^ nameString.
fc07976462e8 Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents: 9940
diff changeset
   203
    ].
fc07976462e8 Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents: 9940
diff changeset
   204
    ^ nameString utf8Encoded.
fc07976462e8 Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents: 9940
diff changeset
   205
! !
fc07976462e8 Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents: 9940
diff changeset
   206
2911
9964e6839a8e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2908
diff changeset
   207
!UnixFilename class methodsFor:'documentation'!
2907
1666bf27f351 VMS changes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
2911
9964e6839a8e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2908
diff changeset
   209
version
17772
6e0b3c06c364 Method reverted to r10532
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17767
diff changeset
   210
    ^ '$Id: UnixFilename.st 10534 2010-07-01 18:21:34Z vranyj1 $'
17734
406b1590afe8 Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17711
diff changeset
   211
!
406b1590afe8 Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17711
diff changeset
   212
406b1590afe8 Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17711
diff changeset
   213
version_CVS
17772
6e0b3c06c364 Method reverted to r10532
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17767
diff changeset
   214
    ^ 'Header: /cvs/stx/stx/libbasic/UnixFilename.st,v 1.16 2009/10/28 14:02:12 cg Exp ยง'
17761
b0e5971141bc Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17735
diff changeset
   215
!
17734
406b1590afe8 Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17711
diff changeset
   216
17761
b0e5971141bc Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17735
diff changeset
   217
version_SVN
17772
6e0b3c06c364 Method reverted to r10532
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17767
diff changeset
   218
    ^ '$Id: UnixFilename.st 10534 2010-07-01 18:21:34Z vranyj1 $'
17761
b0e5971141bc Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17735
diff changeset
   219
! !
17767
a4a32df3aa5e merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17761
diff changeset
   220
17772
6e0b3c06c364 Method reverted to r10532
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17767
diff changeset
   221