473,397 Members | 1,974 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

use chmod() in C

I want to use function chmod() to remove all attribution of a file in C, but i don't know how!
Can you help me!
Sep 25 '08 #1
6 10687
boxfish
469 Expert 256MB
I don't know if this is what you're looking for, but you can use the system() function to have a C program execute a command.
Sep 25 '08 #2
for example, I have a file as SYSTEM.INI, its attributions are HIDDEN, ARCHIVE, READ ONLY. And I want to remove all attribution it has.
Do you understand??? Help me!
Sep 28 '08 #3
JosAH
11,448 Expert 8TB
for example, I have a file as SYSTEM.INI, its attributions are HIDDEN, ARCHIVE, READ ONLY. And I want to remove all attribution it has.
Do you understand??? Help me!
In most (if not all) unices there's the chmod(2) function:

Expand|Select|Wrap|Line Numbers
  1. #include <sys/types.h>
  2. #include <sys/stat.h> 
  3. int chmod(const char *path, mode_t mode);
  4.  
For windows I vaguely remember a 'cacls' method; check it out.

kind regards,

Jos
Sep 28 '08 #4
Banfa
9,065 Expert Mod 8TB
For windows I vaguely remember a 'cacls' method; check it out.
Yes or you could use SetFileAttributes. You would be well advised to call GetFileAttributes first though and only change what you want.
Sep 28 '08 #5
maybe You don't understand my question!
I want to remove all attributions, not set attributions!
ok??
Sep 28 '08 #6
Banfa
9,065 Expert Mod 8TB
maybe You don't understand my question!
I want to remove all attributions, not set attributions!
ok??
May be you have failed to RTFM
Sep 28 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Daniel | last post by:
Hi, From what I read from the PHP manual, chmod on a Windows platform should have no effect, and that seems totally normal (unless someone on sourceforge has a windows port of that!). I...
1
by: Xuan Yuan | last post by:
I'm using Windows XP Professional and have no FTP installed. Instead, I use Command Promt. I need to CHMOD a PHP file, so I type "CHMOD 775 file-path",but get "'CHMOD'is not recognized as an internal...
4
by: Ian N | last post by:
Hi i'm having a problem with file permissions of upload, they appear to be being set to only readable by the administrator, so anyone browsing the site gets a 403 forbidden error when they try and...
5
by: Stewart | last post by:
Hi, I'm working on a program in VC++ right now that needs to set file permissions of a given file to 766 (read/write/execute). Now I've found the _chmod() function in the API help docs, but that...
2
by: Freebird | last post by:
Hello everyone, =] I need your help, I'm creating a script that will work in many servers, and there's this part, where you can update a list, so the script goes from the client's machine to...
1
by: James Colannino | last post by:
Ok, so now I have a very interesting problem, this time related to os.chmod. I have the following in a text file: 0600. My script reads that number as a string and converts it to an integer for...
3
by: webhead | last post by:
I have a web where users can upload photos, but they want to also be able to delete them. The directory can have chmod changes but it won't let me chmod the files and unlink them. I'm assuming it...
3
by: Rik | last post by:
Hello, first of all, my provider sucks, newsserver is down for the #nth time now, offcourse when I have an urgent question.... So this will be me first time using Google Groups, forgive me if...
1
by: lawrence k | last post by:
I've a simple script to transfer some files from one domain to another, with both domains living on the same server. The files in both directories are already chmod 777. Yet after transfer, I try...
1
by: PHPstarter | last post by:
Hiya. I have a file download script which chmods the file permissions to read/downloadable when used. However I have tried to make it so that the same script will chmod the file permissions...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.