Letters to the Editor + CVu Journal Vol 12, #1 - Jan 2000
Browse in : All > Journal Columns > LettersEditor
All > Journals > CVu > 121
Any of these categories - All of these categories

Note: when you create a new publication type, the articles module will automatically use the templates user-display-[publicationtype].xt and user-summary-[publicationtype].xt. If those templates do not exist when you try to preview or display a new article, you'll get this warning :-) Please place your own templates in themes/yourtheme/modules/articles . The templates will get the extension .xt there.

Title: The Wall

Author: Administrator

Date: 08 January 2000 13:15:34 +00:00 or Sat, 08 January 2000 13:15:34 +00:00

Summary: 

Body: 

File Positioning by Waldo Posul

Dear Editor,

I think Waldo is correct in assuming that file positioning is difficult to do with standard C especially if it has to survive file closure. I also think that it is essential to have this functionality in any operating system that is going to be used with large files. So important that any operating system without it will fail. The key, therefore, is to design your own interface so that any system specific code is hidden from your application. This interface should include opening, closing, reading and writing as well as positioning and error reporting. Fortunately this is only a small set of operations and shouldn't impose too great an overhead on an application of any size. Such an interface should come with a test suite so that any implementation can be tested against a common standard.

When it comes to implementation then, depending on the operating system, fgetpos() and fsetpos() may well work as required. If they don't then they may work if text files are opened as binary files or, with Microsoft Windows, you might have to use SetFilePointer(). SetFilePointer() takes two 32 bit values for positioning so that you can have a 63 bit offsets and deal with very large files.

One could try to avoid the problem instead. I would use a database system (creating an application by next week rather than next year). Alternatively you could try lots of small files, such 'a' for everything that begins with the letter 'a', etc, so that fseek() will work. Whatever approach is used I don't like having files open for long periods. I think it makes applications much more vulnerable. I like to be able to open a file, update it and then close it as quickly as possible. To be able to do this means that you must have a persistent file positioning system that Waldo wants.

Don Skene

One subtle problem with such persistent file positioning is that once the file is closed, some other application may access it and make changes. I think that this is one of the motives behind the constraints C places on guaranteed behaviour.

Notes: 

More fields may be available via dynamicdata ..