file size fake

This is a discussion on file size fake within the C++ Programming forums, part of the General Programming Boards category; can i change the size of a file. i mean not by _chsize, but just faking the size so that ...

  1. #1
    darkEagle
    Guest

    Question file size fake

    can i change the size of a file. i mean not by _chsize, but just faking the size so that explorer shows it to what ever we like, with out actually adding or removing contents to/from the file. like i learned how to change name, time , date, attributes, blah blah.. but am curious about this.

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    I doubt that explorer searches through all files to calculate the total size every time you open it , so it must be stored somewhere. If you find out, you can probably modify it in some way...
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,794
    I doubt that explorer searches through all files to calculate the total size every time you open it , so it must be stored somewhere. If you find out, you can probably modify it in some way...
    Maybe the FAT (file allocation table)?
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  4. #4
    Registered User VBprogrammer's Avatar
    Join Date
    Mar 2002
    Posts
    175
    Definatly the fat table - but the problem would be modifying it.
    VC++ 6

  5. #5
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    The only way to change the size of a file would be to change the EOC mark in the FAT. DOS counts the number of clusters every time you do a DIR as it goes through the cluster chains. There is an entry in the DIRENTRY structure that contains the size of the file, but if it does not match the cluster count, DOS will flag an error and Scandisk will have to fix it. However, if you move the EOC mark to a different cluster, and have each added cluster point to the next, you will change the size of the file since DOS counts up to the EOC mark. However, you would just be wasting disk space as the added clusters would be wasted space.

    Each sector is 512 bytes and each cluster is mutliple sectors. So if you had 4 sectors per cluster you would be wasting 4*512 bytes if you moved the EOC mark by one cluster.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 12:44 PM
  2. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 04:02 AM
  3. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 04:54 PM
  4. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 03:39 AM
  5. archive format
    By Nor in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 08-05-2003, 07:01 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21