@@ -171,7 +171,7 @@ class Container extends Locatable, @container {
171
171
* To get the full path, use `getAbsolutePath`.
172
172
*/
173
173
class Folder extends Container , @folder {
174
- override string getAbsolutePath ( ) { folders ( underlyingElement ( this ) , result , _ ) }
174
+ override string getAbsolutePath ( ) { folders ( underlyingElement ( this ) , result ) }
175
175
176
176
override Location getLocation ( ) {
177
177
result .getContainer ( ) = this and
@@ -190,7 +190,7 @@ class Folder extends Container, @folder {
190
190
* DEPRECATED: use `getAbsolutePath` instead.
191
191
* Gets the name of this folder.
192
192
*/
193
- deprecated string getName ( ) { folders ( underlyingElement ( this ) , result , _ ) }
193
+ deprecated string getName ( ) { folders ( underlyingElement ( this ) , result ) }
194
194
195
195
/**
196
196
* DEPRECATED: use `getAbsolutePath` instead.
@@ -208,17 +208,7 @@ class Folder extends Container, @folder {
208
208
* DEPRECATED: use `getBaseName` instead.
209
209
* Gets the last part of the folder name.
210
210
*/
211
- deprecated string getShortName ( ) {
212
- exists ( string longnameRaw , string longname |
213
- folders ( underlyingElement ( this ) , _, longnameRaw ) and
214
- longname = longnameRaw .replaceAll ( "\\" , "/" )
215
- |
216
- exists ( int index |
217
- result = longname .splitAt ( "/" , index ) and
218
- not exists ( longname .splitAt ( "/" , index + 1 ) )
219
- )
220
- )
221
- }
211
+ deprecated string getShortName ( ) { result = this .getBaseName ( ) }
222
212
223
213
/**
224
214
* DEPRECATED: use `getParentContainer` instead.
@@ -242,7 +232,7 @@ class Folder extends Container, @folder {
242
232
* `getStem` and `getExtension`. To get the full path, use `getAbsolutePath`.
243
233
*/
244
234
class File extends Container , @file {
245
- override string getAbsolutePath ( ) { files ( underlyingElement ( this ) , result , _ , _ , _ ) }
235
+ override string getAbsolutePath ( ) { files ( underlyingElement ( this ) , result ) }
246
236
247
237
override string toString ( ) { result = Container .super .toString ( ) }
248
238
@@ -336,7 +326,13 @@ class File extends Container, @file {
336
326
* for example, for "file.tar.gz", this predicate will have the result
337
327
* "tar.gz", while `getExtension` will have the result "gz".
338
328
*/
339
- string getExtensions ( ) { files ( underlyingElement ( this ) , _, _, result , _) }
329
+ string getExtensions ( ) {
330
+ exists ( string name , int firstDotPos |
331
+ name = this .getBaseName ( ) and
332
+ firstDotPos = min ( [ name .indexOf ( "." ) , name .length ( ) - 1 ] ) and
333
+ result = name .suffix ( firstDotPos + 1 )
334
+ )
335
+ }
340
336
341
337
/**
342
338
* Gets the short name of this file, that is, the prefix of its base name up
@@ -351,7 +347,16 @@ class File extends Container, @file {
351
347
* for example, for "file.tar.gz", this predicate will have the result
352
348
* "file", while `getStem` will have the result "file.tar".
353
349
*/
354
- string getShortName ( ) { files ( underlyingElement ( this ) , _, result , _, _) }
350
+ string getShortName ( ) {
351
+ exists ( string name , int firstDotPos |
352
+ name = this .getBaseName ( ) and
353
+ firstDotPos = min ( [ name .indexOf ( "." ) , name .length ( ) ] ) and
354
+ result = name .prefix ( firstDotPos )
355
+ )
356
+ or
357
+ this .getAbsolutePath ( ) = "" and
358
+ result = ""
359
+ }
355
360
}
356
361
357
362
/**
0 commit comments