Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sector Position of a file

Status
Not open for further replies.

Mukesh2375

Programmer
Jan 31, 2003
19
0
0
IN
can anybody tell me if it is possible to find physical position of a file on HDD (i mean sector,cluster position)

Mukesh
 
You will have to explore the FAT (File Allocation Table) of the HDD, assuming you are using FAT16 or FAT32. If using NTFS your in bad luck, as the structures of NTFS are proprietary (by MS). Knowledge is available on the net somewhere, but it's all non-official!
If you need to recover files from a crashed HDD, then get proffesional help, they will know what to do, and have the tools to do it.
If you (only) want to hand-modify a dbf-file, then use FOpen/FSeek/FRead/FWrite/FClose routines, not try to access sectors directly, as it's not very 'multi-user' s-)

HTH
TonHu
 
Dear Tonhu

thanx 4 yr response
actually my objective was to write a function to whom i pass a filename along with full path and it returns me the position of the file on HDD

Mukesh
 
To achieve what? After copying the file(backup/restore?) the location of the file will have changed!

HTH
TonHu
 
This is to build up a security system. Actully the file will be such that its movement viz. deletion, or any kind of modification that changes the HDD position of file is unauthorised. that file b created by me the installer/ developer of the file and if it is found 2 've moved some where else where installed (its position moved), it is unauthorised. this is the concept i mean.

Mukesh
 
The concept will be hard to implement because if any defragmentation is applied to the disk your file is on your file will be moved.

Rob.
 
Most defrag-tools obey the 'rule' that, with fileattributes System, Hidden + Read-Only set to ON, the file should *never* be moved.

The schema used for this protection is like Lotus 1-2-3 that they abandoned years ago, and had a lot of problems related to support, defective hardware that had to be replaced etc., but in a small audience it could work, I guess s-)

I'd advise you to take other measures for application protection. :-|

B.t.w. Are you newly developing a Clipper app in these Windows/ GUI days???????????

HTH
TonHu
 
i 've thought over the pros and cons of doing what i m doing but still want 2 go for it. does anybody know if it is possible and if yes how???

no TonHu i dont think i sounded Windows/Gui anywhere in my question and i m developing in clipper in CUI (v 5.2)

thanx everybody for the suggesions
 
Ok,

A few steps to take:
(not accurate, I did this about 10 years ago on a datarecovery effort after a harddisk crash (99% of all data was recovered), and I'm so glad I don't have to do it again)
- Get indepth knowledge of the FAT (16/32) structures
- Lookup the filename in the directory-list, the first entrypoint in the FAT is there that points to the actual data on disk and to the offset into the FAT that points to the next datablock, and also to the next FAT entry. Zero (or 0xFF ?) means: No more data.
- Find additional info through the FAT if needed

Basically the FAT is directly mapped to the clusters of the HDD.

Have fun ;-)
TonHu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top