Ask about general coding issues or problems here.
2 posts • Page 1 of 1
- Posts: 2272
- Joined: Sat Jul 05, 2003 1:18 pm
- Location: A bunk in the back
I'm not entirely sure what you're looking for. If you want to know if a file is empty (e.g. 0 bytes), simply test with filesize('filename.txt'). If it returns 0, the file is empty. As for '.dat' files -- .dat is an extension that's been used, perhaps, by more programs than any other. My only guess is that perhaps you're referring to the .dat files that contain incomplete downloads in FastTrack network P2P apps like Kazaa and Morpheus, and in this case, I can understand your quandry -- if you start a new download in Kazaa, it creates a file with a name like download00000000000000000000000.dat, and even if it hasn't downloaded a single byte of data, that file isn't zero-length. If I remember correctly, it's about 102kbytes. Well, one way to do this, I suppose, is just test if it's greater than 102kB (or whatever the number is -- I may have it wrong, so do some investigating). The "right" way to do it, though, would probably be to find some documentation about the .dat file format (a cursory Googling found this), then use PHP's fread() and related functions to figure out if the file contains any downloaded data, or just header info, etc. But to do this, you're going to have to get your hands pretty dirty. Good luck.
Who is online
Users browsing this forum: Baidu [Spider], Yahoo [Bot] and 2 guests