72 |
/****************************** Macros *********************************/ |
/****************************** Macros *********************************/ |
73 |
|
|
74 |
/***********************************************************************\ |
/***********************************************************************\ |
75 |
|
* Name : TARGET_NATIVE_FILE_OPEN_CREATE |
76 |
|
* Purpose : create a file |
77 |
|
* Input : - |
78 |
|
* Output : - |
79 |
|
* Return : - |
80 |
|
* Side-effect: unknown |
81 |
|
* Notes : file is created if it does not exist |
82 |
|
\***********************************************************************/ |
83 |
|
|
84 |
|
#ifndef TARGET_NATIVE_FILE_OPEN_CREATE |
85 |
|
#include <sys/types.h> |
86 |
|
#include <sys/stat.h> |
87 |
|
#include <fcntl.h> |
88 |
|
#define TARGET_NATIVE_FILE_OPEN_CREATE(filename,filedescriptor,result) \ |
89 |
|
do { \ |
90 |
|
filedescriptor=open(filename,O_CREAT|O_EXCL|O_RDWR,0777); \ |
91 |
|
result=(filedescriptor>=0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \ |
92 |
|
} while (0) |
93 |
|
#endif |
94 |
|
|
95 |
|
/***********************************************************************\ |
96 |
* Name : TARGET_NATIVE_FILE_OPEN_READ |
* Name : TARGET_NATIVE_FILE_OPEN_READ |
97 |
* Purpose : open an existing file for reading |
* Purpose : open an existing file for reading |
98 |
* Input : - |
* Input : - |
129 |
#include <fcntl.h> |
#include <fcntl.h> |
130 |
#define TARGET_NATIVE_FILE_OPEN_READWRITE(filename,filedescriptor,result) \ |
#define TARGET_NATIVE_FILE_OPEN_READWRITE(filename,filedescriptor,result) \ |
131 |
do { \ |
do { \ |
132 |
filedescriptor=open(filename,O_CREAT|O_RDWR,0666); \ |
filedescriptor=open(filename,O_RDWR,0666); \ |
133 |
result=(filedescriptor>=0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \ |
result=(filedescriptor>=0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \ |
134 |
} while (0) |
} while (0) |
135 |
#endif |
#endif |
361 |
do { \ |
do { \ |
362 |
struct stat __statBuffer; \ |
struct stat __statBuffer; \ |
363 |
\ |
\ |
364 |
result=((lstat(filename,&__statBuffer)==0) && (S_ISREG(__statBuffer.st_mode)))?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \ |
result=((stat(filename,&__statBuffer)==0) && (S_ISREG(__statBuffer.st_mode)))?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \ |
365 |
} while (0) |
} while (0) |
366 |
#endif |
#endif |
367 |
|
|
383 |
do { \ |
do { \ |
384 |
struct stat __statBuffer; \ |
struct stat __statBuffer; \ |
385 |
\ |
\ |
386 |
result=((lstat(filename,&__statBuffer)==0) && (S_ISDIR(__statBuffer.st_mode)))?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \ |
result=((stat(filename,&__statBuffer)==0) && (S_ISDIR(__statBuffer.st_mode)))?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \ |
387 |
} while (0) |
} while (0) |
388 |
#endif |
#endif |
389 |
|
|
498 |
#include <sys/stat.h> |
#include <sys/stat.h> |
499 |
#define TARGET_NATIVE_FILE_MAKE_DIR(name,result) \ |
#define TARGET_NATIVE_FILE_MAKE_DIR(name,result) \ |
500 |
do { \ |
do { \ |
501 |
result=((mkdir(name,S_IRWXU)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR); \ |
result=((mkdir(name,(S_IRWXO|S_IRWXG|S_IRWXU))==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR); \ |
502 |
} while (0) |
} while (0) |
503 |
#endif |
#endif |
504 |
|
|
616 |
#endif /* __TARGET_GENERIC_FILE__ */ |
#endif /* __TARGET_GENERIC_FILE__ */ |
617 |
|
|
618 |
/* end of file */ |
/* end of file */ |
619 |
|
|