mIRC Home    About    Download    Register    News    Help

Print Thread
#44874 29/08/03 10:41 PM
Joined: Dec 2002
Posts: 2,809
C
Hoopy frood
OP Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
I like the new file handling commands, however I'd like to see more (better) support.

/fseek:

add -b and -e flags (beginning/end)
-e would be especially useful. Currently, using the new file handling stuff, if I want to append to the end of the file, I have to /fseek and use $lines. Thats very wasteful since $lines requires the file to be opened (again) and the lines counted. Seeing as how the C fseek function has the ability to immediately jump to the beginning/end of the file, it seems like a good idea to add support for that.

$fgetc is nice, but sometimes you want to know what the next character is without actually increasing the file pointer. For example you might just want to check the next character, but not actually read it. Imho, there should be a $fpeekc which will tell you what the next character is, but not actually increase the file pointer. This would be similar to doing fgetc then ungetc in C. Also, imho the documentation for $fgetc should be updated. It says it returns the next character, it does not, it returns the ASCII code of the next character. Lastly, imho in addition to $ferr and $fopen().err, $ferrstr, and $fopen().errstr would be useful, seeing an $ferr of 12 (made up) is not as useful as seeing a "ÿSMBdo not have permission to open this file" message.

#44875 29/08/03 10:58 PM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
You don't need -b at all, /fseek somename 0 works fine.
As for -e, well, I guess I wouldn't mind about it but you don't have to use $lines():

//fseek somename $file($fopen(somename).fname)

$file() (which is equivalent to $file().size) doesn't open/close any files, so it's a rather fast solution.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#44876 30/08/03 12:40 AM
Joined: Dec 2002
Posts: 2,809
C
Hoopy frood
OP Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
Ok you're right, 0 will work for that, and yes you're right you could use $file(size) however, I'm not 100% sure that will work in all instances. For example, under NTFS, if the file is encrypted/compressed, does $file(size) return the "true" size, meaning will it be the size of the actual data in the file, or the size when encryption/compression is included? Plus, it is still slower. It doesn't require the file to be opened, but it does require disk access because it has to lookup the information for the file. When using -e, no lookup would be needed since all it has to do is jump to the end of the buffer, and the length of the buffer is already known.


Link Copied to Clipboard