Page 1 of 1
is it a safe assumption?
Posted: Mon Nov 22, 2004 2:52 am
by newmember
i'm doing simple file-based guestbook.
$numOfRecs=filesize($path_of_guestbook) / SIZE_OF_RECORD;
this is how i determine total number of records in guestbook
(each record has fixed size)
is it possible that the above line will fail for other OS or other filesystems?
i was thinking of compressed file systems...
what do you think about this?
Posted: Mon Nov 22, 2004 3:16 am
by rehfeld
if your talking about xp's compressed files, i 'think' it would fail.
i say this because i think the stat type of file info is stored in the MFT, so i think checking for filesize
wouldnt actually uncompress the file just to check, it would just use the info in the MFT.... it wouldnt be hard to check.
but, why limit yourself to having to make entries a specific size?
you could just use a delimiter and use explode() to seperate the data, unless your just trying to find an efficient way of checking how many entries w/out openeing the file and processing it. but you could always keep a seperate log file that just has a single number representing the number of entries, which would be a resource friendly way to check.
Posted: Mon Nov 22, 2004 3:30 am
by newmember
ok i see
it is better to be on the safe side then
(with my first try i kept a counter in separate file but then i wanted to make things simplier.)
Posted: Mon Nov 22, 2004 4:17 am
by rehfeld
well, do you need to display the number of entires on pages where you dont need to display the actual entires? often?
if you only need to display the number of entries on pages that actually show or in some way use them, just count them.
its uses very little additional resources if your already opening and reading the entire file.
Code: Select all
$data = file_get_contents('entries.db');
$entries = explode('|', $data);
$num_entries = count($entries);
unless you expect the database file to get very large, those 3 lines of code execute pretty darn fast....