Hiding a file

S

Sync_net

In my application i write some vital data to a file (using fopen,
fwrite, etc etc). Is it possible to change the attributes of this
file(the program itself should be able to do it) so that the file is
hidden, and also if possible restrict the access of the file only to
the program which created it.
 
S

santosh

Sync_net said:
In my application i write some vital data to a file (using fopen,
fwrite, etc etc). Is it possible to change the attributes of this
file(the program itself should be able to do it) so that the file is
hidden, and also if possible restrict the access of the file only to
the program which created it.

The ways to do what your asking for differ from operating system to
operating system. Standard C has no provisions to do what you're
asking. Post is a forum appropriate to the underlying operating system
over which your C program is targetted to run.

File hiding is generally useless and easily reversed. File access
permissions are easily set under UNIX and a bit harder to undo. If you
want to absolutely secure your data, encryption is the only feasible
method.
 
K

Keith Thompson

Sync_net said:
In my application i write some vital data to a file (using fopen,
fwrite, etc etc). Is it possible to change the attributes of this
file(the program itself should be able to do it) so that the file is
hidden, and also if possible restrict the access of the file only to
the program which created it.

There's no way to do this in standard C. Try a newsgroup that's
specific to your operating system.
 
J

Jaspreet

Sync_net said:
In my application i write some vital data to a file (using fopen,
fwrite, etc etc). Is it possible to change the attributes of this
file(the program itself should be able to do it) so that the file is
hidden, and also if possible restrict the access of the file only to
the program which created it.

You would need to invoke OS specific API calls. The call would depend
on what OS you are using. Hiding a file / restricting access is
generally not ir-reversible. You could think of possibly encrypting /
encoding the file.
 
S

Sync_net

encrypting would still not be completely usefull atleast in this case
since it wouldnt stop anyone from deleting the file.
 
S

santosh

Don't top-post. I've fixed your post.

Sync_net said:
encrypting would still not be completely usefull atleast in this case
since it wouldnt stop anyone from deleting the file.

Since standard C, (which is this group's topic), has no way to do the
things you want to do, it would be better if you took your question to
a forum specific to your target platform. Generally file protection is
provided by the operating system, for which specific APIs may need to
be called.

Ask in a more relevant forum.
 
F

Flash Gordon

Sync_net wrote:

Please don't top post. You reply belongs under the text you are replying
to, not above. I would have thought that reading posts here and seeing
how others reply might have given you a clue! I've fixed it this time.
> encrypting would still not be completely usefull atleast in this case
> since it wouldnt stop anyone from deleting the file.

Nothing you do will stop them from reformatting the drive, so you can't
completely prevent this. For what you can do you need system specific
APIs as Jaspreet said, and for those you need to go to a group dedicated
to your system.
 

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
474,183
Messages
2,570,967
Members
47,520
Latest member
KrisMacono

Latest Threads

Top