[STOCK] File copy/cut
Here are some functions that can be useful to us all. You can copy any files with these utilities! (.wav, .mp3, .etcetera)
If you want to use this native on big files it is a possiblity that it will block the HLDS server! So watch out! I will also add the copy folder stocks after I will finish with block wallhack. PHP Code:
|
Re: [STOCK] File copy/cut
You can make only just one stock, just add a bool: arg "bool:bCut", then check for it and delete the file :-D
|
Re: [STOCK] File copy/cut
Oh!! never thinked that this can be possible =o, cool!
With only one stock is something like this right? Code:
And i have some doubts about this: Code:
Why this? i understand that is j + 256 every time when is looping, but why? is becouse fread_blocks and fwrite_blocks read and write 256 characters at the same time? Sry for my english. Good Job! EDIT: Here a simple example using the sock: Code:
|
Re: [STOCK] File copy/cut
Quote:
@Alucard: It is because that string must be loaded fully so we do not store into it the character "^0" which marks the end of the string. That is why the BUFFERSIZE is equal in all of the situations. And the files that we are reading and writing can have sizes over 256. That is why we need to loop. |
Re: [STOCK] File copy/cut
Yes yes i understand why we need the loop, but didn't understand the j += BUFFERSIZE part, but now is clear for me. =p
Now i have another question... whats the diference betwen using bool: and not using it in this case? without bool: can't work? |
Re: [STOCK] File copy/cut
Quote:
I did it with bool just to look nicer. |
Re: [STOCK] File copy/cut
Any specific reason to use 3 lines to know the file size instead of using filesize() ?
|
Re: [STOCK] File copy/cut
Quote:
|
Re: [STOCK] File copy/cut
Ok. Though the tutorial is not about how to determine the size and it should use the existing native for the simplicity. Just my opinion, don't kill me. ^^
By the way, you should open fp_write after the check or adding fclose() into, because if fp_read is null, fp_write won't be closed. |
Re: [STOCK] File copy/cut
This is very useful. Another flag to avoid destination deletion will be nice.
I suggest to use this only at plugin_precache / init / cfg but not in-game because is a blocking function and with big files may cause problems. |
All times are GMT -4. The time now is 15:02. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.