Title:
[ANeff] Bug for: Inconsistencies between I/O tags and functions regarding write, append, and newline
| View in TrackerStatus/Resolution/Reason: Needs Review//HaveNewInfo
Reporter/Name(from Bugbase): Aaron N. / ()
Created: 02/17/2019
Components: File Management
Versions: 2016,2018
Failure Type: Incorrectly functioning
Found In Build/Fixed In Build: 2018.0.0.310739 /
Priority/Frequency: Normal / Most users will encounter
Locale/System: / Windows 10 64 bit
Vote Count: 0
*NOTE* This ticket is a blocker to CF-4203313, b/c Adobe suggests CF-4203313 should add parameters to FileWrite() while other inconsistencies exist. CF-4203313's fix should consider the following inconsistencies, which should be fixed too.
Issues, when using filePath (not fileObject) parameter:
1) fileWrite() matches cffile(action="write",addnewline=false), but fileWriteLine() throws exception; it should match cffile(action="write",addnewline=true)
2) fileAppend() incorrectly appends newline character; it should match cffile(action="append",addnewline=false)
3) fileAppendLine() doesn't exist; it should match cffile(action="append",addnewline=true)
Repro (see comments for Actual vs Expected result):
<!--- write w/o new line --->
<cfscript>
cffile(action="write", file=expandPath("./myfileA1.txt"), output="OverwriteMe", addnewline=false);
cffile(action="write", file=expandPath("./myfileA1.txt"), output="A1", addnewline=false);
writeOutput(fileRead(expandPath("./myfileA1.txt")));
/*
Actual and Expected Result:
-----------
A1
-----------
*/
fileWrite(expandPath("./myfileA2.txt"), "OverwriteMe");
fileWrite(expandPath("./myfileA2.txt"), "A2");
writeOutput(fileRead(expandPath("./myfileA2.txt")));
/*
Actual and Expected Result:
-----------
A2
-----------
*/
</cfscript>
<!--- write w/ new line --->
<cfscript>
cffile(action="write", file=expandPath("./myfileB1.txt"), output="OverwriteMe", addnewline=false);
cffile(action="write", file=expandPath("./myfileB1.txt"), output="B1", addnewline=true);
writeOutput(fileRead(expandPath("./myfileB1.txt")));
/*
Actual and Expected Result:
-----------
B1
-----------
*/
try {
fileWrite(expandPath("./myfileB2.txt"), "OverwriteMe");
fileWriteLine(expandPath("./myfileB2.txt"), "B2");
writeOutput(fileRead(expandPath("./myfileB2.txt")));
}
catch(any e) {writeOutput(e.message);};
/*
Actual Result: exception "The File object must be created by calling FileOpen()."
Expected Result:
-----------
B2
-----------
*/
</cfscript>
<!--- append w/o new line --->
<cfscript>
cffile(action="write", file=expandPath("./myfileC1.txt"), output="AppendToMe", addnewline=false);
cffile(action="append", file=expandPath("./myfileC1.txt"), output="C1", addnewline=false);
writeOutput(fileRead(expandPath("./myfileC1.txt")));
/*
Actual and Expected Result:
-----------
AppendToMeC1
-----------
*/
fileWrite(expandPath("./myfileC2.txt"), "AppendToMe");
fileAppend(expandPath("./myfileC2.txt"), "C2", "utf8");//Issues: 1) charset should be optional and 2) it shouldn't add new line. Since fileAppend() is undocumented, these can still be fixed.
writeOutput(fileRead(expandPath("./myfileC2.txt")));
/*
Actual Result:
-----------
AppendToMeC2
-----------
Expected Result:
-----------
AppendToMeC2
-----------
*/
</cfscript>
<!--- append w/ new line --->
<cfscript>
cffile(action="write", file=expandPath("./myfileD1.txt"), output="AppendToMe", addnewline=false);
cffile(action="append", file=expandPath("./myfileD1.txt"), output="D1", addnewline=true);
writeOutput(fileRead(expandPath("./myfileD1.txt")));
/*
Actual and Expected Result:
-----------
AppendToMeD1
-----------
*/
try {
fileWrite(expandPath("./myfileD2.txt"), "AppendToMe");
fileAppendLine(expandPath("./myfileD2.txt"), "D2");//Issue: FileAppendLine() does not exist
writeOutput(fileRead(expandPath("./myfileD2.txt")));
}
catch(any e) {writeOutput(e.message);}
/*
Actual Result: exception "Variable FILEAPPENDLINE is undefined."
-----------
Expected Result:
-----------
AppendToMeD2
-----------
*/
</cfscript>
Attachments:
Comments: