Delete block from file
Results 1 to 9 of 9

Thread: Delete block from file

  1. #1
    Senior Member
    Join Date
    Jul 2003
    Posts
    166

    Delete block from file

    Hi to all,
    I have a simple problem (question) about C++. I use Windows API functions ReadFile and Write file to "hide" one file in another and then to extract this file. My question is how can I delete the "hidden" file which is exactly a block in the other file? I'm using WindowsXP and Borland C++ Builder 6.0 if this can help.

    P.S. If somebody want I can post the source if the program.
    BGDevS
    [gloworange]www.peaksoft.info [/gloworange]

  2. #2
    Just Another Geek
    Join Date
    Jul 2002
    Location
    Rotterdam, Netherlands
    Posts
    3,401
    Read block.. If block == your inserted data skip next step.. Write block.. repeat until end-of-file.
    Oliver's Law:
    Experience is something you don't get until just after you need it.

  3. #3
    Senior Member
    Join Date
    Jul 2003
    Posts
    166
    Hi,
    I didn't understand your solution. Could you explain ...
    10x
    BGDevS
    [gloworange]www.peaksoft.info [/gloworange]

  4. #4
    Senior Member
    Join Date
    Jul 2003
    Posts
    166
    Hellooo,
    anybody there ... anybody can help me ?
    BGDevS
    [gloworange]www.peaksoft.info [/gloworange]

  5. #5
    Elite Hacker
    Join Date
    Mar 2003
    Posts
    1,407
    Read up until the block you want to delete, then skip that block, then read and write till EOF, then truncate the file to the new size. Not sure how to do that in windows, so I hope you are.

  6. #6
    How is the one file 'hidden' in the other? You could, for example, maybe like

    Read up until the hidden file. Remember where that point in the file is. Read the hidden file into a buffer. Then read the rest of the file into another buffer. Then seek back to the point where the hidden file was, write the rest of the file buffer to that place, and set the EOF after it.

    Edit: If you just don't know the API's and didn't need conceptual stuff I can list those

  7. #7
    AO's Resident Redneck The Texan's Avatar
    Join Date
    Aug 2003
    Location
    Texas
    Posts
    1,539
    Tonto, Just a heads up but if you notice the date on this thread is flashing which prolly means the user got his/her answer by now. Please take a look at the AO FAQ and enjoy your stay here!
    Git R Dun - Ty
    A tribe is wanted

  8. #8
    Sorry about that. Didn't realize that a lot of these threads are pretty old.

  9. #9
    AO's Resident Redneck The Texan's Avatar
    Join Date
    Aug 2003
    Location
    Texas
    Posts
    1,539
    Its no prob I was just giving you the heads up so you dont start your time off here in the red by getting negged when you dont have too.
    Git R Dun - Ty
    A tribe is wanted

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •