file_cpy (STRING* destname, STRING* srcname)

Copies or unpacks the file "srcname" to the file"destname". The source file "srcname" will be searched first in the save_dir folder, then in the work folder. If it isn't in both, but ends with ".pak", it will be also searched in the .wrs resource-files. This way a file within a resource can be unpacked and renamed with it's original file ending. If there already is a file with the name"destname" in the save_dir folder, it will be written over.


destname Name of the destination file without path, STRING* or char*.
srcname Name of the source file without path, STRING* or char*


Nonzero if the action was successful, otherwise 0.




 P  For copying a text file from a .wrs resource, rename the file to "*.pak" and add it to the resource with a BIND statement in a .wdl file, or a PRAGMA_BIND in a .c file (f.i. #define PRAGMA_BIND "mytext.pak";). At runtime, copy the text file from the resource with file_cpy("mytext.txt","mytext.pak");. The resource must either exist in the work folder, or be opened by add_resource.


// copies office1.sav to office2.sav
// unpack a packed a text database file from the game resource

See also:

file_rename, file_delete, file_load, file_date

► latest version online