- Timestamp:
- Feb 14, 2006 9:03:15 PM (19 years ago)
- Location:
- pjproject/trunk/pjlib
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/include/pj/unicode.h
r126 r181 21 21 22 22 #include <pj/types.h> 23 24 25 PJ_BEGIN_DECL 26 23 27 24 28 /** … … 57 61 #if defined(PJ_NATIVE_STRING_IS_UNICODE) && PJ_NATIVE_STRING_IS_UNICODE!=0 58 62 59 # define PJ_DECL_UNICODE_TEMP_BUF(buf,size) wchar_t buf[size]60 # define PJ_STRING_TO_NATIVE(s,buf )pj_ansi_to_unicode( \63 # define PJ_DECL_UNICODE_TEMP_BUF(buf,size) wchar_t buf[size]; 64 # define PJ_STRING_TO_NATIVE(s,buf,max) pj_ansi_to_unicode( \ 61 65 s, strlen(s), \ 62 buf, PJ_ARRAY_SIZE(buf)) 63 # define PJ_TEXT(s) _TEXT(s) 66 buf, max) 67 # define PJ_DECL_ANSI_TEMP_BUF(buf,size) char buf[size]; 68 # define PJ_NATIVE_TO_STRING(cs,buf,max) pj_unicode_to_ansi( \ 69 cs, wcslen(cs), \ 70 buf, max) 64 71 65 72 #else 66 73 67 74 # define PJ_DECL_UNICODE_TEMP_BUF(var,size) 68 # define PJ_STRING_TO_NATIVE(s, buf) (s) 69 # define PJ_TEXT(s) (s) 75 # define PJ_STRING_TO_NATIVE(s,buf,max) ((char*)s) 76 # define PJ_DECL_ANSI_TEMP_BUF(buf,size) 77 # define PJ_NATIVE_TO_STRING(cs,buf,max) ((char*)(const char*)cs) 70 78 71 79 #endif … … 73 81 74 82 83 PJ_END_DECL 84 85 75 86 #endif /* __PJ_UNICODE_H__ */ -
pjproject/trunk/pjlib/src/pj/file_access_win32.c
r126 r181 31 31 PJ_DEF(pj_bool_t) pj_file_exists(const char *filename) 32 32 { 33 PJ_DECL_UNICODE_TEMP_BUF(wfilename,256) 33 34 HANDLE hFile; 34 PJ_DECL_UNICODE_TEMP_BUF(wfilename,256);35 35 36 36 PJ_ASSERT_RETURN(filename != NULL, 0); 37 37 38 hFile = CreateFile(PJ_STRING_TO_NATIVE(filename,wfilename), READ_CONTROL, 38 hFile = CreateFile(PJ_STRING_TO_NATIVE(filename,wfilename,sizeof(wfilename)), 39 READ_CONTROL, 39 40 FILE_SHARE_READ, NULL, 40 41 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); … … 52 53 PJ_DEF(pj_off_t) pj_file_size(const char *filename) 53 54 { 55 PJ_DECL_UNICODE_TEMP_BUF(wfilename,256) 54 56 HANDLE hFile; 55 57 DWORD sizeLo, sizeHi; 56 58 pj_off_t size; 57 PJ_DECL_UNICODE_TEMP_BUF(wfilename,256);58 59 59 60 PJ_ASSERT_RETURN(filename != NULL, -1); 60 61 61 hFile = CreateFile(PJ_STRING_TO_NATIVE(filename, wfilename), READ_CONTROL, 62 hFile = CreateFile(PJ_STRING_TO_NATIVE(filename, wfilename,sizeof(wfilename)), 63 READ_CONTROL, 62 64 FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, 63 65 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); … … 87 89 PJ_DEF(pj_status_t) pj_file_delete(const char *filename) 88 90 { 89 PJ_DECL_UNICODE_TEMP_BUF(wfilename,256) ;91 PJ_DECL_UNICODE_TEMP_BUF(wfilename,256) 90 92 91 93 PJ_ASSERT_RETURN(filename != NULL, PJ_EINVAL); 92 94 93 if (DeleteFile(PJ_STRING_TO_NATIVE(filename,wfilename )) == FALSE)95 if (DeleteFile(PJ_STRING_TO_NATIVE(filename,wfilename,sizeof(wfilename))) == FALSE) 94 96 return PJ_RETURN_OS_ERROR(GetLastError()); 95 97 … … 103 105 PJ_DEF(pj_status_t) pj_file_move( const char *oldname, const char *newname) 104 106 { 107 PJ_DECL_UNICODE_TEMP_BUF(woldname,256) 108 PJ_DECL_UNICODE_TEMP_BUF(wnewname,256) 105 109 BOOL rc; 106 PJ_DECL_UNICODE_TEMP_BUF(woldname,256);107 PJ_DECL_UNICODE_TEMP_BUF(wnewname,256);108 110 109 111 PJ_ASSERT_RETURN(oldname!=NULL && newname!=NULL, PJ_EINVAL); 110 112 111 113 #if PJ_WIN32_WINNT >= 0x0400 112 rc = MoveFileEx(PJ_STRING_TO_NATIVE(oldname,woldname ),113 PJ_STRING_TO_NATIVE(newname,wnewname ),114 rc = MoveFileEx(PJ_STRING_TO_NATIVE(oldname,woldname,sizeof(woldname)), 115 PJ_STRING_TO_NATIVE(newname,wnewname,sizeof(wnewname)), 114 116 MOVEFILE_COPY_ALLOWED|MOVEFILE_REPLACE_EXISTING); 115 117 #else 116 rc = MoveFile(PJ_STRING_TO_NATIVE(oldname, woldname),117 PJ_STRING_TO_NATIVE(newname, wnewname));118 rc = MoveFile(PJ_STRING_TO_NATIVE(oldname,woldname,sizeof(woldname)), 119 PJ_STRING_TO_NATIVE(newname,wnewname,sizeof(wnewname))); 118 120 #endif 119 121 … … 160 162 PJ_DEF(pj_status_t) pj_file_getstat(const char *filename, pj_file_stat *stat) 161 163 { 164 PJ_DECL_UNICODE_TEMP_BUF(wfilename,256) 162 165 HANDLE hFile; 163 166 DWORD sizeLo, sizeHi; 164 167 FILETIME creationTime, accessTime, writeTime; 165 PJ_DECL_UNICODE_TEMP_BUF(wfilename,256);166 168 167 169 PJ_ASSERT_RETURN(filename!=NULL && stat!=NULL, PJ_EINVAL); 168 170 169 hFile = CreateFile(PJ_STRING_TO_NATIVE(filename,wfilename), READ_CONTROL, 171 hFile = CreateFile(PJ_STRING_TO_NATIVE(filename,wfilename,sizeof(wfilename)), 172 READ_CONTROL, 170 173 FILE_SHARE_READ, NULL, 171 174 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); -
pjproject/trunk/pjlib/src/pj/file_io_win32.c
r126 r181 45 45 pj_oshandle_t *fd) 46 46 { 47 PJ_DECL_UNICODE_TEMP_BUF(wpathname,256) ;47 PJ_DECL_UNICODE_TEMP_BUF(wpathname,256) 48 48 HANDLE hFile; 49 49 DWORD dwDesiredAccess = 0; … … 79 79 dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL; 80 80 81 hFile = CreateFile(PJ_STRING_TO_NATIVE(pathname,wpathname ),81 hFile = CreateFile(PJ_STRING_TO_NATIVE(pathname,wpathname,sizeof(wpathname)), 82 82 dwDesiredAccess, dwShareMode, NULL, 83 83 dwCreationDisposition, dwFlagsAndAttributes, NULL);
Note: See TracChangeset
for help on using the changeset viewer.