Re: [ANet-devel] Re: File Management questions
Status: Abandoned
Brought to you by:
benad
From: Chirag K. <ch...@ya...> - 2001-12-19 06:09:41
|
On Tue, Dec 18, 2001 at 01:31:19PM -0500, Benoit Nadeau wrote: | >Here do I assume that the path will be pre-malloc'ed or do I malloc the | >memory required for storing the path? | An ANetMemoryTag implies that: | - The memory was already allocated | - You can get the size of the allocated memory with GetMemoryBlockSize I am not sure how ANetMemoryTag works. I don't think it's possible to GetMemoryBlockSize() on a pointer and find out, how much memory was allocated to it. If ANetMemoryTag was a struct of type: { void *ptr; int size; }, then it would work; ie. storing the size of the memory block along with the location where it is stored. I might be wrong. Let me know what you have thought. | You should actually open the file only in ANetOpenFile and in | ANetRead/WriteFile if the file was not already open. You create the file on | the Write operation if it does not already exist. | Look at: | http://anet.sourceforge.net/docs/devel/lowdesign/html/group__files.html#a0 Fine. I had another suggestion: instead of return 1, 2 or 60, it would be great if we have an error.h with either #define ERROR_FILE_BUSY 60 or a typedef enum { ERROR_FILE_BUSY = 60 } ErrorCode; for the errors. | There's no acutal "seek position" to remember for reads. Look at the | description of ANetReadFile, which is the only function you can use to read | from a file. The "startPos" has to be given explitely each time. Fine. I didn't see that then. | Your code has to work on Linux *only*. This means that you're not forced to | use ANSI C functions. You can use any "Linux-native" function you want. Cool! | So, this means that instead of using ANSI stuff (FILE *), you can use Linux | stuff ("fd": file descriptors, if I'm correct). 'fd' are the usual variable names. The data type is 'int'. | file. So, what you can do is this: | - ANetOpenFile() correctly opens the file in the proper async state. | - ANetGetSetFileAsync(), with the set flag, checks to see if the file is | already open and if the async flag should change. If this is the case, | close the file and re-open it in the new async mode. | - ANetRead/WriteFile assume the actual async state of the file is already | the same as the flag in the ANetFile structure. All ok. | what I did. BTW, we should always use "-Wall" with gcc; I saw | some weird errors. Oh! I'll take care. | About symonds.net: Am I dreaming? Wow! Thanx! :) chyrag. -- Chirag Kantharia, symonds.net/~chyrag/ |