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
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
#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)
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;
bdrv_delete(bs1);
get_tmp_filename(tmp_filename, sizeof(tmp_filename));
+ realpath(filename, backing_filename);
if (bdrv_create(&bdrv_qcow2, tmp_filename,
- total_size, filename, 0) < 0) {
+ total_size, backing_filename, 0) < 0) {
return -1;
}
filename = tmp_filename;
term_printf(" locked=%d", bs->locked);
}
if (bs->drv) {
- term_printf(" file=%s", bs->filename);
- if (bs->backing_file[0] != '\0')
- term_printf(" backing_file=%s", bs->backing_file);
+ term_printf(" file=");
+ term_print_filename(bs->filename);
+ if (bs->backing_file[0] != '\0') {
+ term_printf(" backing_file=");
+ term_print_filename(bs->backing_file);
+ }
term_printf(" ro=%d", bs->read_only);
term_printf(" drv=%s", bs->drv->format_name);
if (bs->encrypted)
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;
"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",