Thread: Make a file hidden

  1. #1
    MFC killed my cat! manutd's Avatar
    Join Date
    Sep 2006
    Location
    Boston, Massachusetts
    Posts
    870

    Make a file hidden

    Does anyone know how to make a file hidden? I am using Dev-C++ and WinXP SP2.
    Silence is better than unmeaning words.
    - Pythagoras
    My blog

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    Hidden from what or who? Are you referring to the windows file attribute?

  3. #3
    MFC killed my cat! manutd's Avatar
    Join Date
    Sep 2006
    Location
    Boston, Massachusetts
    Posts
    870
    Yes. It is a sensitive file that I do not want to normal user to see.
    Silence is better than unmeaning words.
    - Pythagoras
    My blog

  4. #4
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    Perhaps SetFileAttributes will do what you want, although this is more of a Windows specific question.

  5. #5
    MFC killed my cat! manutd's Avatar
    Join Date
    Sep 2006
    Location
    Boston, Massachusetts
    Posts
    870
    Sorry about the windows thing, I didn't know if there was a platform independent solution (which I would love). However, SetFileAttributes worked perfectly for me on windows. Unfortunately, the goal was to be as platform independent as possible (my GUI is using wxWidgets) but ah well.
    Silence is better than unmeaning words.
    - Pythagoras
    My blog

  6. #6
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    Try posting this on the windows board, like daved said you may get more information

  7. #7
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    No. Let it stay here. Hopefully some moderator will move it. Regardless, if you need a platform independent solution, you have one with boost::filesystem
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  8. #8
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    Does boost::filesystem have something like a hidden attribute?

  9. #9
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Hmm... I honestly don't know. It lets you extract data like last modified date...
    But file attributes may be an entire different game.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  10. #10
    MFC killed my cat! manutd's Avatar
    Join Date
    Sep 2006
    Location
    Boston, Massachusetts
    Posts
    870
    I don't think it does. The reason I didn't put this on Windows is that I am looking for a platform independent solution, not one that only works on Windows.
    Silence is better than unmeaning words.
    - Pythagoras
    My blog

  11. #11
    MFC killed my cat! manutd's Avatar
    Join Date
    Sep 2006
    Location
    Boston, Massachusetts
    Posts
    870
    Umm...as I just said my question was not supposed to be windows specific.
    Silence is better than unmeaning words.
    - Pythagoras
    My blog

  12. #12
    MFC killed my cat! manutd's Avatar
    Join Date
    Sep 2006
    Location
    Boston, Massachusetts
    Posts
    870
    Thank you
    Silence is better than unmeaning words.
    - Pythagoras
    My blog

  13. #13
    Registered User divineleft's Avatar
    Join Date
    Jul 2006
    Posts
    158
    change the name to .whatever?

  14. #14
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > Unfortunately, the goal was to be as platform independent as possible (my GUI is using wxWidgets) but ah well.
    So you end up with two small files in the corner of your whole project labelled
    horridWindowsHacks.c
    horridLinuxHacks.c

    Both provide an interface like
    myProtectFile ( const char *filename );

    The windows one implements it using SetFileAttributes
    The Linux one implements it using rename or chmod

    That is, you achieve the portability by concentrating all the non-portable code into as small a place as possible.



    > Does anyone know how to make a file hidden?
    Hidden from whom?
    If it's from yourself in normal file lists, then making it hidden on windows, or making the first letter of the filename a '.' on unix is one way to go.
    If it's from everyone else, then you need to set the read/write ownership to "user only". That would be chmod on unix, but I've no idea what windows would use.

    Are you setting the permissions before or after you've filled the file with sensitive information?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  15. #15
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,273
    >> It is a sensitive file that I do not want to normal user to see.

    I would suggest encrypting it then. Perhaps both 'hide' it and encrypt it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A development process
    By Noir in forum C Programming
    Replies: 37
    Last Post: 07-10-2011, 10:39 PM
  2. Basic text file encoder
    By Abda92 in forum C Programming
    Replies: 15
    Last Post: 05-22-2007, 01:19 PM
  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. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 02:58 AM