Filename.st
changeset 24772 bcb134483fd9
parent 24770 5d449e77d4d8
child 24849 d63fa0c74ab9
equal deleted inserted replaced
24771:c2ac84744237 24772:bcb134483fd9
  6922         ^ self.
  6922         ^ self.
  6923     ].
  6923     ].
  6924 
  6924 
  6925     ^ self species named:
  6925     ^ self species named:
  6926         (self name
  6926         (self name
  6927          , self species suffixSeparator asString
  6927          , self species suffixSeparator
  6928          , aSuffix asString)
  6928          , aSuffix asString)
  6929 
  6929 
  6930     "
  6930     "
  6931      'abc.st' asFilename addSuffix:nil
  6931      'abc.st' asFilename addSuffix:nil
  6932      'a.b.c' asFilename addSuffix:nil
  6932      'a.b.c' asFilename addSuffix:nil
  6949      '/foo/bar/baz.st' asFilename addSuffix:'c'
  6949      '/foo/bar/baz.st' asFilename addSuffix:'c'
  6950      '/foo/bar/baz.c' asFilename addSuffix:'st'
  6950      '/foo/bar/baz.c' asFilename addSuffix:'st'
  6951      '/foo/bar.c/baz.c' asFilename addSuffix:'st'
  6951      '/foo/bar.c/baz.c' asFilename addSuffix:'st'
  6952      '/foo/bar.c/baz' asFilename addSuffix:'st'
  6952      '/foo/bar.c/baz' asFilename addSuffix:'st'
  6953     "
  6953     "
       
  6954 
       
  6955     "Modified: / 09-09-2019 / 16:14:44 / Stefan Vogel"
  6954 !
  6956 !
  6955 
  6957 
  6956 hasSuffix:aSuffixString
  6958 hasSuffix:aSuffixString
  6957     "return true if my suffix is the same as aString.
  6959     "return true if my suffix is the same as aString.
  6958      This cares for systems, where case is ignored in filenames"
  6960      This cares for systems, where case is ignored in filenames"
  7107 withSuffix:aSuffix
  7109 withSuffix:aSuffix
  7108     "return a new filename for the receiver's name with a different suffix.
  7110     "return a new filename for the receiver's name with a different suffix.
  7109      If the name already has a suffix, the new suffix replaces it;
  7111      If the name already has a suffix, the new suffix replaces it;
  7110      otherwise, the new suffix is simply appended to the name."
  7112      otherwise, the new suffix is simply appended to the name."
  7111 
  7113 
       
  7114     |prefixName|
       
  7115 
       
  7116     prefixName := self nameWithoutSuffix.
  7112     aSuffix isEmptyOrNil ifTrue:[
  7117     aSuffix isEmptyOrNil ifTrue:[
  7113         ^ self.
  7118         prefixName = nameString ifTrue:[
       
  7119             "same filename"
       
  7120             ^ self.
       
  7121         ].
       
  7122         ^ self species named:prefixName
  7114     ].
  7123     ].
  7115 
  7124 
  7116     ^ self species named:
  7125     ^ self species named:
  7117         (self nameWithoutSuffix
  7126         (prefixName
  7118          , self class suffixSeparator asString
  7127          , self class suffixSeparator
  7119          , aSuffix asString)
  7128          , aSuffix asString)
  7120 
  7129 
  7121     "
  7130     "
  7122      'abc.st' asFilename withSuffix:nil
  7131      'abc.st' asFilename withSuffix:nil
  7123      'a.b.c' asFilename withSuffix:nil
  7132      'a.b.c' asFilename withSuffix:nil
  7127      '.c' asFilename withSuffix:nil
  7136      '.c' asFilename withSuffix:nil
  7128      'c.' asFilename withSuffix:nil
  7137      'c.' asFilename withSuffix:nil
  7129      '.' asFilename withSuffix:nil
  7138      '.' asFilename withSuffix:nil
  7130 
  7139 
  7131      'abc.st' asFilename withSuffix:'o'
  7140      'abc.st' asFilename withSuffix:'o'
       
  7141      'abc.st' asFilename withSuffix:$o
       
  7142      'abc.st' asFilename withSuffix:''
  7132      'abc' asFilename withSuffix:'o'
  7143      'abc' asFilename withSuffix:'o'
       
  7144      'abc' asFilename withSuffix:''
  7133      'a.b.c' asFilename withSuffix:'o'
  7145      'a.b.c' asFilename withSuffix:'o'
  7134      'a.b.c.' asFilename withSuffix:'o'
  7146      'a.b.c.' asFilename withSuffix:'o'
  7135      '.b.c.' asFilename withSuffix:'o'
  7147      '.b.c.' asFilename withSuffix:'o'
  7136      '.c.' asFilename withSuffix:'o'
  7148      '.c.' asFilename withSuffix:'o'
  7137      '.c' asFilename withSuffix:'o'
  7149      '.c' asFilename withSuffix:'o'
  7143      '/foo/bar.c/baz' asFilename withSuffix:'st'
  7155      '/foo/bar.c/baz' asFilename withSuffix:'st'
  7144     "
  7156     "
  7145 
  7157 
  7146     "Modified: / 07-09-1995 / 11:15:42 / claus"
  7158     "Modified: / 07-09-1995 / 11:15:42 / claus"
  7147     "Modified: / 07-11-2006 / 13:58:45 / cg"
  7159     "Modified: / 07-11-2006 / 13:58:45 / cg"
       
  7160     "Modified (comment): / 09-09-2019 / 15:42:45 / Stefan Vogel"
  7148 !
  7161 !
  7149 
  7162 
  7150 withoutSuffix
  7163 withoutSuffix
  7151     "return a new filename for the receiver's name without the suffix.
  7164     "return a new filename for the receiver's name without the suffix.
  7152      If the name has no suffix, a filename representing the same file as the receiver is returned."
  7165      If the name has no suffix, a filename representing the same file as the receiver is returned."