mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 10:51:54 -04:00
Convert Windows slash to C slash in the disk mount point.
This commit is contained in:
parent
ef1b061022
commit
cfbe9343ae
3 changed files with 25 additions and 1 deletions
2
elem.c
2
elem.c
|
|
@ -268,7 +268,7 @@ struct snapraid_disk* disk_alloc(const char* name, const char* dir)
|
|||
|
||||
disk = malloc_nofail(sizeof(struct snapraid_disk));
|
||||
pathcpy(disk->name, sizeof(disk->name), name);
|
||||
pathcpy(disk->dir, sizeof(disk->dir), dir);
|
||||
pathimport(disk->dir, sizeof(disk->dir), dir);
|
||||
|
||||
/* ensure that the dir terminate with "/" if it isn't empty */
|
||||
pathslash(disk->dir, sizeof(disk->dir));
|
||||
|
|
|
|||
17
util.c
17
util.c
|
|
@ -178,6 +178,23 @@ void pathcpy(char* str, size_t size, const char* src)
|
|||
memcpy(str, src, len + 1);
|
||||
}
|
||||
|
||||
void pathimport(char* str, size_t size, const char* src)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
size_t len;
|
||||
#endif
|
||||
|
||||
pathcpy(str, size, src);
|
||||
|
||||
#ifdef _WIN32
|
||||
/* convert last \ to / */
|
||||
len = strlen(str);
|
||||
if (len && str[len-1] == '\\') {
|
||||
str[len-1] = '/';
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void pathprint(char* str, size_t size, const char* format, ...)
|
||||
{
|
||||
size_t len;
|
||||
|
|
|
|||
7
util.h
7
util.h
|
|
@ -82,6 +82,13 @@ char* strdechex(void* void_data, unsigned data_len, char* str);
|
|||
*/
|
||||
void pathcpy(char* str, size_t size, const char* src);
|
||||
|
||||
/**
|
||||
* Imports a path limiting the size.
|
||||
* In Windows, the last slash, if present, is converted to the C standard.
|
||||
* Aborts if too long.
|
||||
*/
|
||||
void pathimport(char* str, size_t size, const char* src);
|
||||
|
||||
/**
|
||||
* Prints a path.
|
||||
* Aborts if too long.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue