tracker issue : CF-3299625

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

Add isFile() to the language

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Adam Cameron / Adam Cameron (Adam Cameron)

Created: 07/31/2012

Components: Language

Versions: 10.0

Failure Type: Enhancement Request

Found In Build/Fixed In Build: Final /

Priority/Frequency: Minor / Some users will encounter

Locale/System: English / Windows 7

Vote Count: 1

Problem Description:
See for discussion.  Basically there's no way of identifying if a variable is a file handler.

Steps to Reproduce:

Actual Result:

Expected Result:

Any Workarounds:
Use variableName.getClass().getName(), and test it for "".  Not ideal.

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

Watson Bug ID:	3299625

External Customer Info:
External Company:  
External Customer Name: Adam Cameron.
External Customer Email:  
External Test Config: My Hardware and Environment details:



+1, this would be helpful for verification
Vote by External U.
18646 | September 23, 2012 02:16:36 AM GMT
Added a method IsFileObject(fileObj) which will check if the object passed is the fileStream object that you get upon calling FileOpen().
Comment by Rupesh K.
18638 | September 20, 2013 02:12:59 AM GMT
Nice on Rupesh!
Comment by External U.
18639 | September 20, 2013 08:37:05 AM GMT
Hi Adam and Rupesh, 1) If getFileInfo(filePath).type returns "file", then shouldn't isFileObject(fileRead(filePath)) return YES? 2) Also, getFunctionList() doesn't list isFileObject(). Steps to Reproduce: <cfscript> filePath = expandPath("./myfile.txt"); a = fileOpen(filePath); b = fileRead(filePath); writeOutput(isFileObject(a)); writeOutput(isFileObject(b)); writeOutput(getFileInfo(filePath).type); writeOutput(structKeyExists(getFunctionList(), "isFileObject")); </cfscript> Expected Result: YESYESfileYES Actual Result: YESNOfileNO Thanks!, -Aaron
Comment by External U.
18640 | March 01, 2014 08:37:06 PM GMT
The value returned from fileRead() is the contents of the file, not a file object, isn't it? Agree on getFunctionList() though. I wonder what else they have forgotten to add to that. It also indicates a fundamental cock-up in the way that function is implemented if new functions don't just AUTOMATICALLY appear in that list. Not to mention that - in the content of CFML - a function called getFunctionLIST() should return a list. Not a struct. -- Adam
Comment by External U.
18641 | March 01, 2014 08:45:12 PM GMT
Hi Adam, You're right, fileRead() returns the contents - not an object =P And I agree w/ you: getFunctionList() should return a *list* that *automatically* contains all function names. I remember seeing where you parsed the tag names from taglib.cftld (that was cool - didn't know that file existed). When I saw that, I thought: Adobe should add getTagList() =) Possible isObject() doc bug/ER: ----------------------------------------- The isObject() doc says it returns true for ColdFusion objects and false for integers, strings, dates, structs, query objects, and XML objects. For clarification, it should probably also mention that isObject() returns true for file objects (tested it w/ isObject(fileOpen(expandPath("./myFile.ext")))). Possible isPDFFile() or isImageFile()/isSpreadsheetFile() bug: ---------------------------------------------------------------------------------- isPDFFile(pdfObj) returns NO, but isImageFile(imgObj) and isSpreadsheetFile(sheetObj) return an exception: "Complex object types cannot be converted to simple values." The 3 is*File() functions should behave the same. Either isPDFFile(pdfObj) should return an exception, or isImageFile(imgObj) and isSpreadsheetFile(sheetObj) should return NO. Thanks!, -Aaron
Comment by External U.
18642 | March 01, 2014 11:03:35 PM GMT
Regarding my last comment: "Possible isObject() doc bug/ER" (filed as CF-4104246) "Possible isPDFFile() or isImageFile()/isSpreadsheetFile() bug" (this is no longer a bug b/c isImageFile(imgObj) and isSpreadsheetFile(sheetObj) now return NO instead of throwing an exception) Thanks!, -Aaron
Comment by External U.
18643 | January 06, 2016 03:05:33 AM GMT
This work is incomplete; the docs are missing: This just 404s. Pls reopen and complete the work.
Comment by External U.
18644 | January 06, 2016 11:05:50 AM GMT
Here is the link,
Comment by Saurav G.
18645 | October 13, 2017 07:04:16 AM GMT