mirror of
https://github.com/RubyMetric/chsrc.git
synced 2025-01-22 20:44:01 +08:00
Ensure dir test first
This commit is contained in:
parent
3d1b1473f8
commit
c9fb2c6dff
|
@ -633,33 +633,14 @@ static void
|
|||
chsrc_ensure_dir (const char *dir)
|
||||
{
|
||||
dir = xy_uniform_path (dir);
|
||||
char *mkdir_cmd = NULL;
|
||||
|
||||
if (xy_on_windows)
|
||||
if (xy_dir_exist (dir))
|
||||
{
|
||||
// 也可以用 opendir() #include <dirent.h>
|
||||
DWORD attr = GetFileAttributesA(dir);
|
||||
|
||||
if (attr == INVALID_FILE_ATTRIBUTES)
|
||||
{
|
||||
// Q: 我们应该报错吗?
|
||||
// chsrc_error ("目录路径错误");
|
||||
// exit (Exit_MatinerIssue);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (attr & FILE_ATTRIBUTE_DIRECTORY)
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int status = system (xy_2strjoin ("test -d ", dir));
|
||||
if (0==status)
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
// 不存在就生成
|
||||
char *mkdir_cmd = NULL;
|
||||
if (xy_on_windows)
|
||||
{
|
||||
mkdir_cmd = "md "; // 已存在时返回 errorlevel = 1
|
||||
|
|
Loading…
Reference in New Issue
Block a user