@@ -171,7 +171,7 @@ class Container extends Locatable, @container {
171171 * To get the full path, use `getAbsolutePath`.
172172 */
173173class Folder extends Container , @folder {
174- override string getAbsolutePath ( ) { folders ( underlyingElement ( this ) , result , _ ) }
174+ override string getAbsolutePath ( ) { folders ( underlyingElement ( this ) , result ) }
175175
176176 override Location getLocation ( ) {
177177 result .getContainer ( ) = this and
@@ -190,7 +190,7 @@ class Folder extends Container, @folder {
190190 * DEPRECATED: use `getAbsolutePath` instead.
191191 * Gets the name of this folder.
192192 */
193- deprecated string getName ( ) { folders ( underlyingElement ( this ) , result , _ ) }
193+ deprecated string getName ( ) { folders ( underlyingElement ( this ) , result ) }
194194
195195 /**
196196 * DEPRECATED: use `getAbsolutePath` instead.
@@ -208,17 +208,7 @@ class Folder extends Container, @folder {
208208 * DEPRECATED: use `getBaseName` instead.
209209 * Gets the last part of the folder name.
210210 */
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 ( ) }
222212
223213 /**
224214 * DEPRECATED: use `getParentContainer` instead.
@@ -242,7 +232,7 @@ class Folder extends Container, @folder {
242232 * `getStem` and `getExtension`. To get the full path, use `getAbsolutePath`.
243233 */
244234class File extends Container , @file {
245- override string getAbsolutePath ( ) { files ( underlyingElement ( this ) , result , _ , _ , _ ) }
235+ override string getAbsolutePath ( ) { files ( underlyingElement ( this ) , result ) }
246236
247237 override string toString ( ) { result = Container .super .toString ( ) }
248238
@@ -336,7 +326,13 @@ class File extends Container, @file {
336326 * for example, for "file.tar.gz", this predicate will have the result
337327 * "tar.gz", while `getExtension` will have the result "gz".
338328 */
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+ }
340336
341337 /**
342338 * 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 {
351347 * for example, for "file.tar.gz", this predicate will have the result
352348 * "file", while `getStem` will have the result "file.tar".
353349 */
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+ }
355360}
356361
357362/**
0 commit comments