Protecting files

W

wallacej

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
 
V

Victor Bazarov

wallacej said:
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?
 
H

Howard

wallacej said:
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
 
K

Karl Heinz Buchegger

wallacej said:
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++
 
W

wallacej

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
 
T

Thomas Matthews

wallacej said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top