mirror of
https://github.com/git/git.git
synced 2026-04-01 12:30:09 +02:00
On Windows, mark directory hidden when starting with dot.
In Windows a file or directory starting with a dot is not automatically hidden. So lets mark it as hidden when such a directory is created. This fixes msysGit issue 288. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Acked-by: Johannes Sixt <j6t@kdbg.org>
This commit is contained in:
committed by
Johannes Schindelin
parent
e8a0ecc3ac
commit
33dc23c8d1
@@ -119,6 +119,32 @@ static int err_win_to_posix(DWORD winerr)
|
||||
return error;
|
||||
}
|
||||
|
||||
static int make_hidden(const char *path)
|
||||
{
|
||||
DWORD attribs = GetFileAttributes(path);
|
||||
if (SetFileAttributes(path, FILE_ATTRIBUTE_HIDDEN | attribs))
|
||||
return 0;
|
||||
errno = err_win_to_posix(GetLastError());
|
||||
return -1;
|
||||
}
|
||||
|
||||
#undef mkdir
|
||||
int mingw_mkdir(const char *path, int mode)
|
||||
{
|
||||
int ret = mkdir(path);
|
||||
if (!ret) {
|
||||
/*
|
||||
* In Windows a file or dir starting with a dot is not
|
||||
* automatically hidden. So lets mark it as hidden when
|
||||
* such a directory is created.
|
||||
*/
|
||||
const char *start = basename((char*)path);
|
||||
if (*start == '.')
|
||||
return make_hidden(path);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
#undef open
|
||||
int mingw_open (const char *filename, int oflags, ...)
|
||||
{
|
||||
|
||||
@@ -98,12 +98,6 @@ static inline int fcntl(int fd, int cmd, long arg)
|
||||
* simple adaptors
|
||||
*/
|
||||
|
||||
static inline int mingw_mkdir(const char *path, int mode)
|
||||
{
|
||||
return mkdir(path);
|
||||
}
|
||||
#define mkdir mingw_mkdir
|
||||
|
||||
static inline int mingw_unlink(const char *pathname)
|
||||
{
|
||||
/* read-only files cannot be removed */
|
||||
@@ -143,6 +137,9 @@ int readlink(const char *path, char *buf, size_t bufsiz);
|
||||
* replacements of existing functions
|
||||
*/
|
||||
|
||||
int mingw_mkdir(const char *path, int mode);
|
||||
#define mkdir mingw_mkdir
|
||||
|
||||
int mingw_open (const char *filename, int oflags, ...);
|
||||
#define open mingw_open
|
||||
|
||||
|
||||
Reference in New Issue
Block a user