Author Topic: How to give write permission to a windows file from c code  (Read 5468 times)

mrsudhi

  • Guest
How to give write permission to a windows file from c code
« on: February 18, 2013, 04:59:52 am »
I have written a C program, one of the operation it does is copying contents from one file to other.
The original file is usually a read only file.
If the file is read only, the the copy of file just doesn't happen, but if I manually give read permission to the file it works fine.

In unix, I know I can call system(chmod 777 abc.c) to give write permission to file.
But my question is how can I achieve this in windows?
i.e. how can I give write permission to a windows file from C code?

Thanks in advance.
« Last Edit: February 18, 2013, 05:07:57 am by mrsudhi »

Offline Radek

  • Multiple posting newcomer
  • *
  • Posts: 104
Re: How to give write permission to a windows file from c code
« Reply #1 on: February 18, 2013, 06:13:28 am »
You need to create a (new) r/w file, read the contents of the source and write it to the target. You must pass if the source can be read. A "high level copy" can copy permissions, too, something you must avoid. But this is not a Code Blocks related problem.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: How to give write permission to a windows file from c code
« Reply #2 on: February 18, 2013, 07:07:00 pm »
Unrelated to C::B and therefore violating our forum rules.

Topic locked !