|
-
Apr 14th, 2002, 05:59 PM
#1
Thread Starter
PowerPoster
files
what is the difference between random acces files and sequential access?
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
-
Apr 14th, 2002, 07:58 PM
#2
Thread Starter
PowerPoster
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
-
Apr 14th, 2002, 10:42 PM
#3
Lively Member
A random access files records are all fixed length, therefore any record can be found without searching all the other records (by simply using a record key), oh and any record can be inserted or deleted without affecting the whole file.
A sequential access file has records with different lengths so the data must be inserted into the file sequentially, and the whole file is changed each time a record is inserted or deleted.
-
Apr 15th, 2002, 12:55 PM
#4
I think he's not talking about special files with "records" or such, just about a flag of CreateFile (FILE_FLAG_RANDOM_ACCESS vs. FILE_FLAG_SEQUENTIAL_SCAN). Right?
It is only about optimizing. Sequential files are optimized for reading them from the front to the end, with no jumps or anything. Random access files are optimized for jumping around in the file (using SetFilePointer, which is the API version of fseek). Random access is mostly used in structured files, like archives. Archives usually start with a header that tells which files are contained and the offset to the file's data. These offsets are used with SetFilePointer to move to the data. Such jumps are faster when you use a random access file.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Apr 15th, 2002, 12:59 PM
#5
Lively Member
ya i dunno, i was just talking about the general idea of sequential/random files in C. nothing i said really applies to anything winAPI related.
although all data files can be considered to have records, there doesnt have to be anything special about it.
-
Apr 15th, 2002, 02:50 PM
#6
nearly all data files are structured, but not all are used with records (look at word docs for example)
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Apr 15th, 2002, 02:56 PM
#7
there is a simple uncompressed file packaging format which would be good for random access. It is structured like this:
1) The header. This hypothetical structures describes the header:
struct header
{
int num_entries;
header_entry entries[];
};
struct header_entry
{
char filename[]; // '\0'-terminated
int offset;
int length;
};
num_entries is the number of files the package contains. entries is a variable-lenth array with length num_entries of the structure header_entry. filename is a null-terminated string that contains the filename of the packaced file. offset is the offset from the package start to the file data. length is the length of the file.
2) data. This is just a concatenation of all packaged files.
Because of this format, random jumping is very likely.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Apr 15th, 2002, 05:16 PM
#8
Monday Morning Lunatic
Originally posted by CornedBee
nearly all data files are structured, but not all are used with records (look at word docs for example)
Did you know...
...Word files are the same structure as PowerPoint, Excel, Binder files
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Apr 15th, 2002, 06:30 PM
#9
Thread Starter
PowerPoster
thanks. i was more talking about the core concept of it, i'm not using the API at this point.
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
-
Apr 16th, 2002, 05:40 AM
#10
Composite documents, probably...
Did you know the mdb format sucks? An empty db (no tables, no queries, no nothing) consumes 50 KB. Adding one table without entries pushes that up to 80 KB. A file currently opened in Access needs twice the space as when closed.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Apr 16th, 2002, 01:31 PM
#11
Monday Morning Lunatic
Originally posted by CornedBee
Composite documents, probably...
Did you know the mdb format sucks? An empty db (no tables, no queries, no nothing) consumes 50 KB. Adding one table without entries pushes that up to 80 KB. A file currently opened in Access needs twice the space as when closed.
Not surprised really. Compacting helps quite a lot though, if you need to send it anywhere.
Same with any Office document - if you want to put it on a floppy, for example, use Save As and put it into a new file (but don't edit that file once saved) and it'll be a lot smaller.
Microsoft had a utility in the Platform SDK that let you browse the contents of Office-style documents.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|