]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/findlib/bfile.c
This commit was manufactured by cvs2svn to create tag
[bacula/bacula] / bacula / src / findlib / bfile.c
index 2e2ae4f6081bf2f6e9558f2b6e2a108d971fc14f..dc09ace024777bb4edd86491f9d70d97bbf1c286 100644 (file)
@@ -64,33 +64,33 @@ const char *stream_to_ascii(int stream)
 
    switch (stream) {
    case STREAM_GZIP_DATA:
-      return "GZIP data";
+      return _("GZIP data");
    case STREAM_SPARSE_GZIP_DATA:
-      return "GZIP sparse data";
+      return _("GZIP sparse data");
    case STREAM_WIN32_DATA:
-      return "Win32 data";
+      return _("Win32 data");
    case STREAM_WIN32_GZIP_DATA:
-      return "Win32 GZIP data";
+      return _("Win32 GZIP data");
    case STREAM_UNIX_ATTRIBUTES:
-      return "File attributes";
+      return _("File attributes");
    case STREAM_FILE_DATA:
-      return "File data";
+      return _("File data");
    case STREAM_MD5_SIGNATURE:
-      return "MD5 signature";
+      return _("MD5 signature");
    case STREAM_UNIX_ATTRIBUTES_EX:
-      return "Extended attributes";
+      return _("Extended attributes");
    case STREAM_SPARSE_DATA:
-      return "Sparse data";
+      return _("Sparse data");
    case STREAM_PROGRAM_NAMES:
-      return "Program names";
+      return _("Program names");
    case STREAM_PROGRAM_DATA:
-      return "Program data";
+      return _("Program data");
    case STREAM_SHA1_SIGNATURE:
-      return "SHA1 signature";
+      return _("SHA1 signature");
    case STREAM_MACOS_FORK_DATA:
-      return "HFS+ resource fork";
+      return _("HFS+ resource fork");
    case STREAM_HFSPLUS_ATTRIBUTES:
-      return "HFS+ Finder Info";
+      return _("HFS+ Finder Info");
    default:
       sprintf(buf, "%d", stream);
       return (const char *)buf;
@@ -167,7 +167,7 @@ bool have_win32_api()
  * Return 1 if we support the stream
  *        0 if we do not support the stream
  */
-bool is_stream_supported(int stream)
+bool is_restore_stream_supported(int stream)
 {
    /* No Win32 backup on this machine */
    switch (stream) {
@@ -211,16 +211,21 @@ HANDLE bget_handle(BFILE *bfd)
 int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode)
 {
    POOLMEM *win32_fname;
-   DWORD dwaccess, dwflags, dwshare;
+   POOLMEM *win32_fname_wchar;
 
+   DWORD dwaccess, dwflags, dwshare;
+   
    /* 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 USE_WIN32_UNICODE
-   WCHAR win32_fname_wchar[MAX_PATH_UNICODE];
-   UTF8_2_wchar(win32_fname_wchar, win32_fname, MAX_PATH_UNICODE);
-#endif
+   if (!(p_CreateFileA || p_CreateFileW))
+      return 0;
+
+   if (p_CreateFileW && p_MultiByteToWideChar)               
+      UTF8_2_wchar(&win32_fname_wchar, win32_fname);
 
    if (flags & O_CREAT) {             /* Create */
       if (bfd->use_backup_api) {
@@ -231,18 +236,27 @@ int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode)
          dwflags = 0;
       }
 
-
-#if USE_WIN32_UNICODE   
-        bfd->fh = CreateFileW(win32_fname_wchar,
-#else
-      bfd->fh = CreateFile(win32_fname,
-#endif
+   // unicode or ansii open for create write
+   if (p_CreateFileW && p_MultiByteToWideChar) {   
+      bfd->fh = p_CreateFileW((LPCWSTR)win32_fname_wchar,
              dwaccess,                /* Requested access */
              0,                       /* Shared mode */
              NULL,                    /* SecurityAttributes */
              CREATE_ALWAYS,           /* CreationDisposition */
              dwflags,                 /* Flags and attributes */
              NULL);                   /* TemplateFile */
+   }
+   else {
+      bfd->fh = p_CreateFileA(win32_fname,
+             dwaccess,                /* Requested access */
+             0,                       /* Shared mode */
+             NULL,                    /* SecurityAttributes */
+             CREATE_ALWAYS,           /* CreationDisposition */
+             dwflags,                 /* Flags and attributes */
+             NULL);                   /* TemplateFile */
+   }
+
+
       bfd->mode = BF_WRITE;
 
    } else if (flags & O_WRONLY) {     /* Open existing for write */
@@ -254,17 +268,27 @@ int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode)
          dwflags = 0;
       }
 
-#if USE_WIN32_UNICODE
-          bfd->fh = CreateFileW(win32_fname_wchar,
-#else
-      bfd->fh = CreateFile(win32_fname,
-#endif
+   // unicode or ansii open for open existing write
+   if (p_CreateFileW && p_MultiByteToWideChar) {   
+      bfd->fh = p_CreateFileW((LPCWSTR)win32_fname_wchar,
              dwaccess,                /* Requested access */
              0,                       /* Shared mode */
              NULL,                    /* SecurityAttributes */
              OPEN_EXISTING,           /* CreationDisposition */
              dwflags,                 /* Flags and attributes */
              NULL);                   /* TemplateFile */
+   }
+   else {
+      bfd->fh = p_CreateFileA(win32_fname,
+             dwaccess,                /* Requested access */
+             0,                       /* Shared mode */
+             NULL,                    /* SecurityAttributes */
+             OPEN_EXISTING,           /* CreationDisposition */
+             dwflags,                 /* Flags and attributes */
+             NULL);                   /* TemplateFile */
+
+   }
+
       bfd->mode = BF_WRITE;
 
    } else {                           /* Read */
@@ -278,17 +302,26 @@ int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode)
          dwshare = FILE_SHARE_READ|FILE_SHARE_WRITE;
       }
 
-#if USE_WIN32_UNICODE
-          bfd->fh = CreateFileW(win32_fname_wchar,
-#else
-      bfd->fh = CreateFile(win32_fname,
-#endif      
+      // unicode or ansii open for open existing read
+   if (p_CreateFileW && p_MultiByteToWideChar) {   
+      bfd->fh = p_CreateFileW((LPCWSTR)win32_fname_wchar,
              dwaccess,                /* Requested access */
              dwshare,                 /* Share modes */
              NULL,                    /* SecurityAttributes */
              OPEN_EXISTING,           /* CreationDisposition */
              dwflags,                 /* Flags and attributes */
              NULL);                   /* TemplateFile */
+   }
+   else {
+      bfd->fh = p_CreateFileA(win32_fname,
+             dwaccess,                /* Requested access */
+             dwshare,                 /* Share modes */
+             NULL,                    /* SecurityAttributes */
+             OPEN_EXISTING,           /* CreationDisposition */
+             dwflags,                 /* Flags and attributes */
+             NULL);                   /* TemplateFile */
+   }
+
       bfd->mode = BF_READ;
    }
 
@@ -300,6 +333,7 @@ int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode)
    }
    bfd->errmsg = NULL;
    bfd->lpContext = NULL;
+   free_pool_memory(win32_fname_wchar);
    free_pool_memory(win32_fname);
    return bfd->mode == BF_CLOSED ? -1 : 1;
 }
@@ -498,7 +532,7 @@ bool set_prog(BFILE *bfd, char *prog, JCR *jcr)
 }
 
 
-bool is_stream_supported(int stream)
+bool is_restore_stream_supported(int stream)
 {
    /* No Win32 backup on this machine */
    switch (stream) {
@@ -589,13 +623,10 @@ int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode)
 int bopen_rsrc(BFILE *bfd, const char *fname, int flags, mode_t mode)
 {
    POOLMEM *rsrc_fname;
-   size_t fname_len;
 
-   fname_len = strlen(fname);
    rsrc_fname = get_pool_memory(PM_FNAME);
-   bstrncpy(rsrc_fname, fname, fname_len + 1);
-   bstrncpy(rsrc_fname + fname_len, _PATH_RSRCFORKSPEC,
-      strlen(_PATH_RSRCFORKSPEC) + 1);
+   pm_strcpy(rsrc_fname, fname);
+   pm_strcat(rsrc_fname, _PATH_RSRCFORKSPEC);
    bopen(bfd, rsrc_fname, flags, mode);
    free_pool_memory(rsrc_fname);
    return bfd->fid;