snow_zhangy Posted April 10, 2014 Share Posted April 10, 2014 there is a move file / rename file or delete file but missing copy file function. So I can easily copy one file from one dir to another dir. Also if there is a simliar function engine.filesystem.getFileName for file system will be great. Because i want to use it in usc script. right now it's very hard to locate the assets from the relative path as some assets are inside a directory which not show in the path. example: valley demo assets are relative to valley folder but the vally actually inside demos folder. I need this 2 features for an assets packing tool Link to comment
unclebob Posted June 9, 2014 Share Posted June 9, 2014 Hello Yang, We're working on node export tool which will be able to export assets from one project to another. As for copy function, there's no function like that in script API yet it's very simple to write one in the script. Or you can use this code: int copy_file(string old_path,string new_path) { File input = new File(); if(input.open(old_path,"rb") == 0) { delete input; return 0; } File output = new File(); if(output.open(new_path,"wb") == 0) { input.close(); delete input; delete output; return 0; } long target_size = input.getSize(); long actual_size = output.writeStream(input,target_size); input.close(); delete input; output.close(); delete output; return (target_size == actual_size); } Link to comment
snow_zhangy Posted June 10, 2014 Author Share Posted June 10, 2014 hi Andrey: That's what i did after suggested by Ulf. it's a workaround. but i just think it would be included in the api since it's very basic file operation. thanks Link to comment
silent Posted August 28, 2014 Share Posted August 28, 2014 Implemented, the feature will be available in the next SDK update. How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
danni.coy Posted September 2, 2014 Share Posted September 2, 2014 In the meantime if you are on Windows or Linux you can grab the file copy function from Oilrush :) Link to comment
Recommended Posts