[SourcePawn] Copy File in binary mode
SP has fully working FILE IO functions that are wrapped C/C++`s IO functions.
now i am writing here a small snippet that let u copy file in binary mode. u have no need to use OS`s command to copy a file via some extension, and that kind of work is not so recommended. anyway, here we go, yea, code is SHORT Code:
|
Re: [SourcePawn] Copy File in binary mode
well, getting file`s size is not needed at all, but i am added it while i am coding and lazy to remove it, so, let us thing that as part of nice snippet k
|
Re: [SourcePawn] Copy File in binary mode
PHP Code:
While we're at it, PHP Code:
|
Re: [SourcePawn] Copy File in binary mode
thanks dude, instead of uploading untested snippet, i just tested it myself, and now it works fine.k
|
Re: [SourcePawn] Copy File in binary mode
It seems like you could avoid the wasted-space by either reading size=4 chunks or using String:buf[];. Not 100% sure of the implications of either, though.
Also note that you can move files with RenameFile(). Edit: Quote:
|
Re: [SourcePawn] Copy File in binary mode
well, i saw ReadFile function`s code of SM.
and, ReadFile function was designed to work with cell type buffer. and, when we are forcing to read 4 bytes from file and there is only 2 bytes left to read on file, the fread of C will make 2 result : read 2 bytes of junk data from outbound of file with file`s left 2 byte or dont read left 2 bytes at all. both of them are bad result, so that is why i made it to read byte by byte. this memory waist is not so good but also not so critical. and, when i tried c:\\somefilename to open, that try was failed. |
Re: [SourcePawn] Copy File in binary mode
performance will be better using 4k blocks i guess...
|
Re: [SourcePawn] Copy File in binary mode
that kind of optimize will not work cuz of struct of ReadFile function of SM.
it reads exact size that we specificated as size of each element per time. so..unless they make those functions to work with String Array.... well, for it, they also should have some String -> cell byte copy function and vice vera? |
| All times are GMT -4. The time now is 21:53. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.