diff options
author | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2007-01-07 17:27:07 +0000 |
---|---|---|
committer | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2007-01-07 17:27:07 +0000 |
commit | 3b9f94e1a8757ac223a51c662e4278aab738f0cd (patch) | |
tree | ff0f0a0413be1247b17313316206288e45b6921b /block.c | |
parent | f5e25d7007544415dbfd3fdf0778604c9b7c68b7 (diff) |
win32 block device fixes (initial patch by kazu)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2305 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'block.c')
-rw-r--r-- | block.c | 39 |
1 files changed, 28 insertions, 11 deletions
@@ -56,12 +56,6 @@ 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; @@ -70,7 +64,11 @@ int path_is_absolute(const char *path) 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 +91,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 +174,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) @@ -996,7 +1005,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 +1019,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", |