tracker issue : CF-4116201

select a category, or use search below
(searches all categories and all time range)

Add isFile and isDirectory functions

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/NotABug

Reporter/Name(from Bugbase): Peter Freitag / Peter Freitag (Peter Freitag)

Created: 02/10/2016

Components: File Management

Versions: 11.0

Failure Type: Enhancement Request

Found In Build/Fixed In Build: CF11_Final /

Priority/Frequency: Trivial / Unknown

Locale/System: English / Mac 10 All

Vote Count: 3

Currently if you want to determine if a path is pointing to a file or a directory you need to use the getFileInfo function and look at the type key of the struct returned. The getFileInfo function throws an exception if the path does not exist, so you then need to check both directoryExists(path) OR fileExists(path) before you can use the getFileInfo() function for this purpose.

Further getFileInfo returns a lot of information that is not necessary for this use case.

I purpose adding two new builtin functions:

isFile(path) which would be equivalent to: fileExists(path) && getFileInfo(path).type == "file" or createObject("java", "").init(path).isFile()

isDirectory(path) which would be equivalent to: directoryExists(path) && getFileInfo(path).type == "directory" or createObject("java", "").init(path).isDirectory()

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	4116201

External Customer Info:
External Company:  
External Customer Name: Peter Freitag
External Customer Email:  
External Test Config: My Hardware and Environment details: Mac



Folks - it seams that fileExists only returns true when it is a file that exists, so it would be doing the same as isFile. I was not sure about unix file systems but testing on Linux fileExists("/tmp/") returns false and directoryExists("/tmp/") returns true. So there is really not a need for another function.
Comment by External U.
4808 | February 11, 2016 10:20:56 AM GMT
fileExists() and directoryExists() actually serve the purpose. Please let us know about this. Thanks, Akhila.
Comment by Akhila K.
4809 | February 12, 2016 04:46:49 AM GMT
Akhila that is correct, please close the bug, thanks
Comment by External U.
4810 | February 12, 2016 09:28:01 AM GMT