mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-23 00:43:00 -05:00
dll: fuse: fuse_mount: now also accepts cygwin paths
This commit is contained in:
parent
31e6f15eaf
commit
86025aa30b
@ -177,6 +177,7 @@ struct fuse_flock
|
|||||||
MemAlloc, MemFree, \
|
MemAlloc, MemFree, \
|
||||||
fsp_fuse_daemonize, \
|
fsp_fuse_daemonize, \
|
||||||
fsp_fuse_set_signal_handlers, \
|
fsp_fuse_set_signal_handlers, \
|
||||||
|
0/*conv_to_win_path*/, \
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#define FSP_FUSE_ENV_INIT \
|
#define FSP_FUSE_ENV_INIT \
|
||||||
@ -185,6 +186,7 @@ struct fuse_flock
|
|||||||
malloc, free, \
|
malloc, free, \
|
||||||
fsp_fuse_daemonize, \
|
fsp_fuse_daemonize, \
|
||||||
fsp_fuse_set_signal_handlers, \
|
fsp_fuse_set_signal_handlers, \
|
||||||
|
0/*conv_to_win_path*/, \
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -226,6 +228,7 @@ struct fuse_flock
|
|||||||
malloc, free, \
|
malloc, free, \
|
||||||
fsp_fuse_daemonize, \
|
fsp_fuse_daemonize, \
|
||||||
fsp_fuse_set_signal_handlers, \
|
fsp_fuse_set_signal_handlers, \
|
||||||
|
fsp_fuse_conv_to_win_path, \
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -244,7 +247,8 @@ struct fsp_fuse_env
|
|||||||
void (*memfree)(void *);
|
void (*memfree)(void *);
|
||||||
int (*daemonize)(int);
|
int (*daemonize)(int);
|
||||||
int (*set_signal_handlers)(void *);
|
int (*set_signal_handlers)(void *);
|
||||||
void (*reserved[4])();
|
char *(*conv_to_win_path)(const char *);
|
||||||
|
void (*reserved[3])();
|
||||||
};
|
};
|
||||||
|
|
||||||
FSP_FUSE_API void FSP_FUSE_API_NAME(fsp_fuse_signal_handler)(int sig);
|
FSP_FUSE_API void FSP_FUSE_API_NAME(fsp_fuse_signal_handler)(int sig);
|
||||||
@ -348,6 +352,13 @@ static inline int fsp_fuse_set_signal_handlers(void *se)
|
|||||||
#undef FSP_FUSE_SET_SIGNAL_HANDLER
|
#undef FSP_FUSE_SET_SIGNAL_HANDLER
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline char *fsp_fuse_conv_to_win_path(const char *path)
|
||||||
|
{
|
||||||
|
void *cygwin_create_path(unsigned, const void *);
|
||||||
|
return cygwin_create_path(
|
||||||
|
0/*CCP_POSIX_TO_WIN_A*/ | 0x100/*CCP_RELATIVE*/,
|
||||||
|
path);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -177,23 +177,55 @@ FSP_FUSE_API struct fuse_chan *fsp_fuse_mount(struct fsp_fuse_env *env,
|
|||||||
const char *mountpoint, struct fuse_args *args)
|
const char *mountpoint, struct fuse_args *args)
|
||||||
{
|
{
|
||||||
struct fuse_chan *ch = 0;
|
struct fuse_chan *ch = 0;
|
||||||
|
WCHAR TempMountPointBuf[MAX_PATH], MountPointBuf[MAX_PATH];
|
||||||
int Size;
|
int Size;
|
||||||
|
|
||||||
if (0 == mountpoint)
|
if (0 == mountpoint || '\0' == mountpoint[0] ||
|
||||||
mountpoint = "";
|
('*' == mountpoint[0] && '\0' == mountpoint[1]))
|
||||||
|
{
|
||||||
|
MountPointBuf[0] = L'*';
|
||||||
|
MountPointBuf[1] = L'\0';
|
||||||
|
Size = 2 * sizeof(WCHAR);
|
||||||
|
}
|
||||||
|
else if (
|
||||||
|
(
|
||||||
|
('A' <= mountpoint[0] && mountpoint[0] <= 'Z') ||
|
||||||
|
('a' <= mountpoint[0] && mountpoint[0] <= 'z')
|
||||||
|
) &&
|
||||||
|
':' == mountpoint[1] && '\0' == mountpoint[2])
|
||||||
|
{
|
||||||
|
MountPointBuf[0] = mountpoint[0];
|
||||||
|
MountPointBuf[1] = ':';
|
||||||
|
MountPointBuf[2] = '\0';
|
||||||
|
Size = 3 * sizeof(WCHAR);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char *win_mountpoint = 0;
|
||||||
|
|
||||||
Size = MultiByteToWideChar(CP_UTF8, 0, mountpoint, -1, 0, 0);
|
if (0 != env->conv_to_win_path)
|
||||||
if (0 == Size)
|
mountpoint = win_mountpoint = env->conv_to_win_path(mountpoint);
|
||||||
goto fail;
|
|
||||||
|
|
||||||
ch = fsp_fuse_obj_alloc(env, sizeof *ch + Size * sizeof(WCHAR));
|
Size = 0;
|
||||||
|
if (0 != mountpoint &&
|
||||||
|
0 != MultiByteToWideChar(CP_UTF8, 0, mountpoint, -1, TempMountPointBuf, MAX_PATH))
|
||||||
|
Size = GetFullPathNameW(TempMountPointBuf, MAX_PATH, MountPointBuf, 0);
|
||||||
|
|
||||||
|
env->memfree(win_mountpoint);
|
||||||
|
|
||||||
|
if (0 == Size || MAX_PATH <= Size)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
mountpoint = 0;
|
||||||
|
Size = (Size + 1) * sizeof(WCHAR);
|
||||||
|
}
|
||||||
|
|
||||||
|
ch = fsp_fuse_obj_alloc(env, sizeof *ch + Size);
|
||||||
if (0 == ch)
|
if (0 == ch)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
ch->MountPoint = (PVOID)ch->Buffer;
|
ch->MountPoint = (PVOID)ch->Buffer;
|
||||||
Size = MultiByteToWideChar(CP_UTF8, 0, mountpoint, -1, ch->MountPoint, Size);
|
memcpy(ch->MountPoint, MountPointBuf, Size);
|
||||||
if (0 == Size)
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
return ch;
|
return ch;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user