ColdFusion 8 has given a new definition to file operations
as compared to ColdFusion 7. In ColdFusion 7, cffile is the tag responsible for
handling all file operations (for reading a file, for appending data to a file
content, to write to a file and other operations). Though cffile is able to
give justification to its work, there are some places or situations which cffile
fails to perform perfectly. Lets us consider the first situation where we have
two files – one file is of size of only some kb and the other one is some 100
kb bigger the first file. For performing file operations on the first file, the
cffile tag works fine, but when it comes to the second case where the file size
is bigger, it may not perform perfectly. This is because cffile tag can perform
operations at a single shot only. So for reading or writing, we need to read
data at one time or provide the whole content at one shot, i.e. the whole
content needs to be kept in memory.
When the file size is bigger it can create a burden on the
server and if the load is very high, it can lead to OutOfMemory error on the server.
It would also lead to slow down in performance of the server as it is required
to allocate and deallocate larger part of memory which would lead to more
frequent garbage collection cycles. One more demerit with cffile is that it
cannot be used within cfscript as cfscript does not support ColdFusion tags. So
to perform file operations within a script we need to wind up all the required
instructions in a function and call that function within the script. Keeping
these problems in mind, in ColdFusion 8 a number of functions have been added to
address these disadvantages.