Windows: mark newly-created files whose name starts with a dot as hidden

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Acked-by: Johannes Sixt <j6t@kdbg.org>
This commit is contained in:
Johannes Schindelin
2009-08-09 19:12:17 +02:00
parent c1b3bedfac
commit 5cdb2faf0e
2 changed files with 14 additions and 3 deletions

View File

@@ -135,7 +135,7 @@ core.fileMode::
core.hideDotFiles::
(Windows-only) If true (which is the default), mark newly-created
directories whose name starts with a dot as hidden.
directories and files whose name starts with a dot as hidden.
core.ignoreCygwinFSTricks::
This option is only used by Cygwin implementation of Git. If false,

View File

@@ -2,9 +2,11 @@
#include "win32.h"
#include <conio.h>
#include <winioctl.h>
#include <shellapi.h>
#include "../strbuf.h"
#include <shellapi.h>
extern int hide_dotfiles;
unsigned int _CRT_fmode = _O_BINARY;
static int err_win_to_posix(DWORD winerr)
{
@@ -131,7 +133,6 @@ static int make_hidden(const char *path)
#undef mkdir
int mingw_mkdir(const char *path, int mode)
{
extern int hide_dotfiles;
int ret = mkdir(path);
if (!ret && hide_dotfiles) {
/*
@@ -167,6 +168,16 @@ int mingw_open (const char *filename, int oflags, ...)
if (attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_DIRECTORY))
errno = EISDIR;
}
if ((oflags & O_CREAT) && fd >= 0 && hide_dotfiles) {
/*
* In Windows a file or dir starting with a dot is not
* automatically hidden. So lets mark it as hidden when
* such a file is created.
*/
const char *start = basename((char*)filename);
if (*start == '.' && make_hidden(filename))
warning("Could not mark '%s' as hidden.", filename);
}
return fd;
}