Use UTC/localtime flag in M48Txx
[qemu] / block.c
diff --git a/block.c b/block.c
index 9aebaa0..269a397 100644 (file)
--- a/block.c
+++ b/block.c
@@ -56,21 +56,24 @@ static int bdrv_write_em(BlockDriverState *bs, int64_t sector_num,
 static BlockDriverState *bdrv_first;
 static BlockDriver *first_drv;
 
-#ifdef _WIN32
-#define PATH_SEP '\\'
-#else
-#define PATH_SEP '/'
-#endif
-
 int path_is_absolute(const char *path)
 {
     const char *p;
+#ifdef _WIN32
+    /* specific case for names like: "\\.\d:" */
+    if (*path == '/' || *path == '\\')
+        return 1;
+#endif
     p = strchr(path, ':');
     if (p)
         p++;
     else
         p = path;
-    return (*p == PATH_SEP);
+#ifdef _WIN32
+    return (*p == '/' || *p == '\\');
+#else
+    return (*p == '/');
+#endif
 }
 
 /* if filename is absolute, just copy it to dest. Otherwise, build a
@@ -93,7 +96,15 @@ void path_combine(char *dest, int dest_size,
             p++;
         else
             p = base_path;
-        p1 = strrchr(base_path, PATH_SEP);
+        p1 = strrchr(base_path, '/');
+#ifdef _WIN32
+        {
+            const char *p2;
+            p2 = strrchr(base_path, '\\');
+            if (!p1 || p2 > p1)
+                p1 = p2;
+        }
+#endif
         if (p1)
             p1++;
         else
@@ -168,7 +179,10 @@ int bdrv_create(BlockDriver *drv,
 #ifdef _WIN32
 void get_tmp_filename(char *filename, int size)
 {
-    tmpnam(filename);
+    char temp_dir[MAX_PATH];
+    
+    GetTempPath(MAX_PATH, temp_dir);
+    GetTempFileName(temp_dir, "qem", 0, filename);
 }
 #else
 void get_tmp_filename(char *filename, int size)
@@ -308,8 +322,8 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
                BlockDriver *drv)
 {
     int ret, open_flags;
-    char tmp_filename[1024];
-    char backing_filename[1024];
+    char tmp_filename[PATH_MAX];
+    char backing_filename[PATH_MAX];
     
     bs->read_only = 0;
     bs->is_temporary = 0;
@@ -996,7 +1010,11 @@ char *get_human_readable_size(char *buf, int buf_size, int64_t size)
 char *bdrv_snapshot_dump(char *buf, int buf_size, QEMUSnapshotInfo *sn)
 {
     char buf1[128], date_buf[128], clock_buf[128];
+#ifdef _WIN32
+    struct tm *ptm;
+#else
     struct tm tm;
+#endif
     time_t ti;
     int64_t secs;
 
@@ -1006,11 +1024,15 @@ char *bdrv_snapshot_dump(char *buf, int buf_size, QEMUSnapshotInfo *sn)
                  "ID", "TAG", "VM SIZE", "DATE", "VM CLOCK");
     } else {
         ti = sn->date_sec;
-#ifndef _WIN32
+#ifdef _WIN32
+        ptm = localtime(&ti);
+        strftime(date_buf, sizeof(date_buf),
+                 "%Y-%m-%d %H:%M:%S", ptm);
+#else
         localtime_r(&ti, &tm);
-#endif
         strftime(date_buf, sizeof(date_buf),
                  "%Y-%m-%d %H:%M:%S", &tm);
+#endif
         secs = sn->vm_clock_nsec / 1000000000;
         snprintf(clock_buf, sizeof(clock_buf),
                  "%02d:%02d:%02d.%03d",
@@ -1219,6 +1241,7 @@ void bdrv_init(void)
     bdrv_register(&bdrv_vpc);
     bdrv_register(&bdrv_vvfat);
     bdrv_register(&bdrv_qcow2);
+    bdrv_register(&bdrv_parallels);
 }
 
 void *qemu_aio_get(BlockDriverState *bs, BlockDriverCompletionFunc *cb,