git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2054
91ce42f0-d328-0410-95d8-
f526ca767f89
if (p_GetFileAttributesExW) {
unix_name_to_win32(&ff_pkt->sys_fname, ff_pkt->fname);
if (p_GetFileAttributesExW) {
unix_name_to_win32(&ff_pkt->sys_fname, ff_pkt->fname);
- WCHAR szBuf[MAX_PATH_UNICODE];
- UTF8_2_wchar(szBuf, ff_pkt->sys_fname, MAX_PATH_UNICODE);
+ POOLMEM* pwszBuf = get_pool_memory (PM_FNAME);
+ UTF8_2_wchar(&pwszBuf, ff_pkt->sys_fname);
- if (!p_GetFileAttributesExW(szBuf, GetFileExInfoStandard,
- (LPVOID)&atts)) {
+ BOOL b=p_GetFileAttributesExW((LPCWSTR) pwszBuf, GetFileExInfoStandard, (LPVOID)&atts);
+ free_pool_memory(pwszBuf);
+
+ if (!b) {
win_error(jcr, "GetFileAttributesExW:", ff_pkt->sys_fname);
return STREAM_UNIX_ATTRIBUTES;
}
}
win_error(jcr, "GetFileAttributesExW:", ff_pkt->sys_fname);
return STREAM_UNIX_ATTRIBUTES;
}
}
if (!p_GetFileAttributesExA)
return STREAM_UNIX_ATTRIBUTES;
if (!p_GetFileAttributesExA)
return STREAM_UNIX_ATTRIBUTES;
if (!(atts.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
if (p_SetFileAttributesW) {
if (!(atts.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
if (p_SetFileAttributesW) {
- WCHAR szBuf[MAX_PATH_UNICODE];
- UTF8_2_wchar(szBuf, win32_ofile, MAX_PATH_UNICODE);
-
- if (!SetFileAttributesW(szBuf, atts.dwFileAttributes & SET_ATTRS)) {
- win_error(jcr, "SetFileAttributesW:", win32_ofile);
- }
+ POOLMEM* pwszBuf = get_pool_memory (PM_FNAME);
+ UTF8_2_wchar(&pwszBuf, win32_ofile);
+
+ BOOL b=SetFileAttributesW((LPCWSTR)pwszBuf, atts.dwFileAttributes & SET_ATTRS);
+ free_pool_memory(pwszBuf);
+
+ if (!b)
+ win_error(jcr, "SetFileAttributesW:", win32_ofile);
- if (!SetFileAttributes(win32_ofile, atts.dwFileAttributes & SET_ATTRS)) {
- win_error(jcr, "SetFileAttributesA:", win32_ofile);
+ if (!SetFileAttributes(win32_ofile, atts.dwFileAttributes & SET_ATTRS)) {
+ win_error(jcr, "SetFileAttributesA:", win32_ofile);
int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode)
{
POOLMEM *win32_fname;
int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode)
{
POOLMEM *win32_fname;
- DWORD dwaccess, dwflags, dwshare;
- WCHAR win32_fname_wchar[MAX_PATH_UNICODE];
+ POOLMEM *win32_fname_wchar;
+ DWORD dwaccess, dwflags, dwshare;
+
/* Convert to Windows path format */
win32_fname = get_pool_memory(PM_FNAME);
/* Convert to Windows path format */
win32_fname = get_pool_memory(PM_FNAME);
+ win32_fname_wchar = get_pool_memory(PM_FNAME);
+
unix_name_to_win32(&win32_fname, (char *)fname);
if (!(p_CreateFileA || p_CreateFileW))
return 0;
unix_name_to_win32(&win32_fname, (char *)fname);
if (!(p_CreateFileA || p_CreateFileW))
return 0;
- if (p_CreateFileW){
- UTF8_2_wchar(win32_fname_wchar, win32_fname, MAX_PATH_UNICODE);
- }
+ if (p_CreateFileW && p_MultiByteToWideChar)
+ UTF8_2_wchar(&win32_fname_wchar, win32_fname);
if (flags & O_CREAT) { /* Create */
if (bfd->use_backup_api) {
if (flags & O_CREAT) { /* Create */
if (bfd->use_backup_api) {
}
// unicode or ansii open for create write
}
// unicode or ansii open for create write
- if (p_CreateFileW) {
- bfd->fh = p_CreateFileW(win32_fname_wchar,
+ if (p_CreateFileW && p_MultiByteToWideChar) {
+ bfd->fh = p_CreateFileW((LPCWSTR)win32_fname_wchar,
dwaccess, /* Requested access */
0, /* Shared mode */
NULL, /* SecurityAttributes */
dwaccess, /* Requested access */
0, /* Shared mode */
NULL, /* SecurityAttributes */
}
// unicode or ansii open for open existing write
}
// unicode or ansii open for open existing write
- if (p_CreateFileW) {
- bfd->fh = p_CreateFileW(win32_fname_wchar,
+ if (p_CreateFileW && p_MultiByteToWideChar) {
+ bfd->fh = p_CreateFileW((LPCWSTR)win32_fname_wchar,
dwaccess, /* Requested access */
0, /* Shared mode */
NULL, /* SecurityAttributes */
dwaccess, /* Requested access */
0, /* Shared mode */
NULL, /* SecurityAttributes */
}
// unicode or ansii open for open existing read
}
// unicode or ansii open for open existing read
- if (p_CreateFileW) {
- bfd->fh = p_CreateFileW(win32_fname_wchar,
+ if (p_CreateFileW && p_MultiByteToWideChar) {
+ bfd->fh = p_CreateFileW((LPCWSTR)win32_fname_wchar,
dwaccess, /* Requested access */
dwshare, /* Share modes */
NULL, /* SecurityAttributes */
dwaccess, /* Requested access */
dwshare, /* Share modes */
NULL, /* SecurityAttributes */
}
bfd->errmsg = NULL;
bfd->lpContext = NULL;
}
bfd->errmsg = NULL;
bfd->lpContext = NULL;
+ free_pool_memory(win32_fname_wchar);
free_pool_memory(win32_fname);
return bfd->mode == BF_CLOSED ? -1 : 1;
}
free_pool_memory(win32_fname);
return bfd->mode == BF_CLOSED ? -1 : 1;
}
#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
+#ifndef POOLMEM
+typedef char POOLMEM;
+#endif
+
// unicode enabling of win 32 needs some defines and functions
// unicode enabling of win 32 needs some defines and functions
-#define MAX_PATH_UNICODE 32767
#define MAX_PATH_UTF8 MAX_PATH*3
int wchar_2_UTF8(char *pszUTF, const WCHAR *pszUCS, int cchChar = MAX_PATH_UTF8);
#define MAX_PATH_UTF8 MAX_PATH*3
int wchar_2_UTF8(char *pszUTF, const WCHAR *pszUCS, int cchChar = MAX_PATH_UTF8);
-int UTF8_2_wchar(WCHAR *pszUCS, const char *pszUTF, int cchWideChar = MAX_PATH);
+int UTF8_2_wchar(POOLMEM **pszUCS, const char *pszUTF);