197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
|
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
|
+
-
-
+
+
|
*/
int file_setexe(const char *zFilename, int onoff){
int rc = 0;
#if !defined(_WIN32)
struct stat buf;
if( stat(zFilename, &buf)!=0 ) return 0;
if( onoff ){
int targetMode = (buf.st_mode & 0444)>>2;
if( (buf.st_mode & 0111)!=0111 ){
chmod(zFilename, buf.st_mode | 0111);
if( (buf.st_mode & 0111)!=targetMode ){
chmod(zFilename, buf.st_mode | targetMode);
rc = 1;
}
}else{
if( (buf.st_mode & 0111)!=0 ){
chmod(zFilename, buf.st_mode & ~0111);
rc = 1;
}
|