Protecting files

Discussion in 'C++' started by wallacej, May 19, 2005.

  1. wallacej

    wallacej Guest

    Hi

    Is there a way to protect system files, eg .ini files but still allow
    access to them from C++ code?

    As an example I have a settings file called SIMS.INI. This file is
    often accessed through C++ using FILE and fstream. I do not want a
    user to be able to open/edit/delete etc. this file.

    Thanks
     
    wallacej, May 19, 2005
    #1
    1. Advertising

  2. wallacej wrote:
    > Is there a way to protect system files, eg .ini files but still allow
    > access to them from C++ code?
    >
    > As an example I have a settings file called SIMS.INI. This file is
    > often accessed through C++ using FILE and fstream. I do not want a
    > user to be able to open/edit/delete etc. this file.


    Is there a C++ _language_ question here somewhere that I am not seeing?
     
    Victor Bazarov, May 19, 2005
    #2
    1. Advertising

  3. wallacej

    Howard Guest

    "wallacej" <> wrote in message
    news:...
    > Hi
    >
    > Is there a way to protect system files, eg .ini files but still allow
    > access to them from C++ code?
    >
    > As an example I have a settings file called SIMS.INI. This file is
    > often accessed through C++ using FILE and fstream. I do not want a
    > user to be able to open/edit/delete etc. this file.
    >
    > Thanks
    >


    You'd need to ask in a newsgroup for the platform (Windows), not here. File
    permissions are platform-specific.

    But... there are a couple options, at least. One would be to not use a text
    file, but instead use a binary file, and encode the contents in some simple
    manner so that it's not easily readable by your users. Another might be to
    mark it as read-only (using whatever system API calls are available on
    Windows), such that the user gets a "hint" that it shouldn't be touched.
    That wouldn't stop them if they really wanted to, but it might help. Or,
    you could hide your file in some Windows-specific directory, and give it a
    name they would never associate with your application. Or any combination
    of the above.

    In any case, you need to ask in a windows newsgroup if you've got questions
    specific to that operating system.

    -Howard
     
    Howard, May 19, 2005
    #3
  4. wallacej wrote:
    >
    > Hi
    >
    > Is there a way to protect system files, eg .ini files but still allow
    > access to them from C++ code?
    >
    > As an example I have a settings file called SIMS.INI. This file is
    > often accessed through C++ using FILE and fstream. I do not want a
    > user to be able to open/edit/delete etc. this file.


    Then you should check what capabilities your operating system offers
    to protect files.

    Note: operating system, not C++

    --
    Karl Heinz Buchegger
     
    Karl Heinz Buchegger, May 19, 2005
    #4
  5. wallacej

    wallacej Guest

    Cheers,

    I thought that maybe there was some way to protect the file, un-protect
    it for access and then re-protect it after; all within the C++
    _language_ .

    wallace
     
    wallacej, May 19, 2005
    #5
  6. wallacej wrote:

    > Cheers,
    >
    > I thought that maybe there was some way to protect the file, un-protect
    > it for access and then re-protect it after; all within the C++
    > _language_ .
    >
    > wallace
    >

    Sorry, but the _standard_ C++ language only provides
    a minimal interface for files. Protecting them, passwords,
    and redirection are left for the operating system.

    --
    Thomas Matthews

    C++ newsgroup welcome message:
    http://www.slack.net/~shiva/welcome.txt
    C++ Faq: http://www.parashift.com/c -faq-lite
    C Faq: http://www.eskimo.com/~scs/c-faq/top.html
    alt.comp.lang.learn.c-c++ faq:
    http://www.comeaucomputing.com/learn/faq/
    Other sites:
    http://www.josuttis.com -- C++ STL Library book
    http://www.sgi.com/tech/stl -- Standard Template Library
     
    Thomas Matthews, May 19, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ryan Moore

    Protecting image files

    Ryan Moore, Apr 6, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    583
    richlm
    Apr 16, 2004
  2. UJ
    Replies:
    18
    Views:
    589
  3. tshad

    Protecting files

    tshad, Dec 23, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    377
    Spam Catcher
    Dec 23, 2005
  4. darrel

    PWD protecting individual files.

    darrel, Jun 19, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    340
    Shawn
    Jun 20, 2006
  5. Ken Fine
    Replies:
    1
    Views:
    694
    Steve C. Orr [MCSD, MVP, CSM, ASP Insider]
    Jul 31, 2007
Loading...

Share This Page