Thread: More file attributes from DOS

  1. #1
    Registered User
    Join Date
    Mar 2010
    Posts
    2

    Angry More file attributes from DOS

    Hi.
    I have an question:
    Where do save attributes in file?
    I opened file with hexeditor but which offset is for attributes in hex?

  2. #2
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    That depends, very much on file system and OS.

  3. #3
    Registered User
    Join Date
    Mar 2010
    Posts
    2
    in windows

  4. #4
    Registered User
    Join Date
    Feb 2010
    Posts
    9

    Smile

    Use the following program for getting the file attributes using stat function.

    Code:
    #include <stdio.h>
    #include <sys/stat.h>
    
    struct stat stResult;
    
    main()
    {
    if(stat("file.txt", &stResult) == 0)
    {
    printf("Filesize: %i\n", stResult.st_size);
    printf("Block size: %i\n",stResult.st_blksize);
    }
    else
    {
    printf("Couldn't get file attributes.");
    }
    }

  5. #5
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,834
    File attributes are not stored in the file's data area no matter which OS. In some cases there is a file header which is normally invisible to the programmer. The file's name, attribute flags, timestamp and size are in the directory. Specific location information is in some linked list structure referenced from the directory entry as well.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. To find the memory leaks without using any tools
    By asadullah in forum C Programming
    Replies: 2
    Last Post: 05-12-2008, 07:54 AM
  2. Need Help Fixing My C Program. Deals with File I/O
    By Matus in forum C Programming
    Replies: 7
    Last Post: 04-29-2008, 07:51 PM
  3. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  4. Batch file programming
    By year2038bug in forum Tech Board
    Replies: 10
    Last Post: 09-05-2005, 03:30 PM
  5. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 03:39 AM