Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
onlyoffice_core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
onlyoffice_core
Commits
a0b93fd1
Commit
a0b93fd1
authored
Jan 16, 2017
by
Oleg Korshul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
96cea25b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
100 deletions
+11
-100
DesktopEditor/common/Directory.h
DesktopEditor/common/Directory.h
+11
-100
No files found.
DesktopEditor/common/Directory.h
View file @
a0b93fd1
/*
/*
* (c) Copyright Ascensio System SIA 2010-2016
*
* This program is a free software product. You can redistribute it and/or
...
...
@@ -439,32 +439,7 @@ namespace NSDirectory
}
static
std
::
wstring
CreateTempFileWithUniqueName
(
const
std
::
wstring
&
strFolderPathRoot
,
std
::
wstring
Prefix
)
{
#if defined(_WIN32) || defined (_WIN64)
wchar_t
pBuffer
[
MAX_PATH
+
1
];
memset
(
pBuffer
,
0
,
sizeof
(
wchar_t
)
*
(
MAX_PATH
+
1
));
/*unRet = */
GetTempFileNameW
(
strFolderPathRoot
.
c_str
(),
Prefix
.
c_str
(),
0
,
pBuffer
);
return
std
::
wstring
(
pBuffer
);
#else
char
pcRes
[
MAX_PATH
];
if
(
NULL
==
pcRes
)
return
_T
(
""
);
Prefix
=
strFolderPathRoot
+
FILE_SEPARATOR_STR
+
Prefix
+
_T
(
"_XXXXXX"
);
std
::
wstring
w_str
=
Prefix
.
c_str
();
std
::
string
a_str
=
stringWstingToUtf8String
(
w_str
);
memcpy
(
pcRes
,
a_str
.
c_str
(),
a_str
.
length
());
pcRes
[
a_str
.
length
()]
=
'\0'
;
int
res
=
mkstemp
(
pcRes
);
if
(
-
1
!=
res
)
close
(
res
);
std
::
string
sRes
=
pcRes
;
return
stringUtf8ToWString
(
sRes
);
#endif
return
NSFile
::
CFileBinary
::
CreateTempFileWithUniqueName
(
strFolderPathRoot
,
Prefix
);
}
static
std
::
wstring
CreateDirectoryWithUniqueName
(
const
std
::
wstring
&
strFolderPathRoot
)
{
...
...
@@ -494,97 +469,33 @@ namespace NSDirectory
}
return
pcTemplate
;
#else
std
::
string
pcTemplate
=
stringWstingToUtf8String
(
strFolderPathRoot
)
+
"/ascXXXXXX"
;
std
::
string
pcTemplate
=
U_TO_UTF8
(
strFolderPathRoot
)
+
"/ascXXXXXX"
;
char
*
pcRes
=
mkdtemp
(
const_cast
<
char
*>
(
pcTemplate
.
c_str
()));
if
(
NULL
==
pcRes
)
return
_T
(
""
)
;
return
L""
;
std
::
string
sRes
=
pcRes
;
return
stringUtf8ToWString
(
sRes
);
return
NSFile
::
CUtf8Converter
::
GetUnicodeStringFromUTF8
((
BYTE
*
)
sRes
.
c_str
(),
(
LONG
)
sRes
.
length
()
);
#endif
}
static
std
::
wstring
GetTempPath
()
{
#if defined(_WIN32) || defined (_WIN64)
wchar_t
pBuffer
[
MAX_PATH
+
1
];
memset
(
pBuffer
,
0
,
sizeof
(
wchar_t
)
*
(
MAX_PATH
+
1
));
::
GetTempPathW
(
MAX_PATH
,
pBuffer
);
std
::
wstring
res
;
res
+=
std
::
wstring
(
pBuffer
);
int
nSeparator1Pos
=
res
.
rfind
(
L"/"
);
if
(
-
1
==
nSeparator1Pos
)
{
nSeparator1Pos
=
res
.
rfind
(
L"
\\
"
);
}
if
(
-
1
==
nSeparator1Pos
)
return
L""
;
return
res
.
substr
(
0
,
nSeparator1Pos
);
#else
char
*
folder
=
getenv
(
"TEMP"
);
if
(
NULL
==
folder
)
folder
=
getenv
(
"TMP"
);
if
(
NULL
==
folder
)
folder
=
getenv
(
"TMPDIR"
);
if
(
NULL
==
folder
)
folder
=
"/tmp"
;
return
stringUtf8ToWString
(
folder
);
#endif
return
NSFile
::
CFileBinary
::
GetTempPath
();
}
static
int
GetFilesCount
(
const
std
::
wstring
&
path
,
const
bool
&
recursive
)
{
CArray
<
std
::
wstring
>
arrFiles
=
NSDirectory
::
GetFiles
(
path
,
recursive
);
#if defined(_WIN32) || defined (_WIN64)
std
::
wstring
pathMask
=
path
+
L"
\\
*"
;
int
filesCount
=
0
;
WIN32_FIND_DATAW
findData
;
HANDLE
findResult
=
FindFirstFileW
(
pathMask
.
c_str
(),
&
findData
);
do
{
if
(
findData
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
)
{
if
(
!
recursive
)
continue
;
if
((
std
::
wstring
)
findData
.
cFileName
==
L"."
)
continue
;
if
((
std
::
wstring
)
findData
.
cFileName
==
L".."
)
continue
;
std
::
wstring
innerPath
=
path
+
L'\\'
+
(
std
::
wstring
)
findData
.
cFileName
;
filesCount
+=
GetFilesCount
(
innerPath
,
recursive
);
}
else
++
filesCount
;
}
while
(
FindNextFileW
(
findResult
,
&
findData
));
FindClose
(
findResult
);
return
filesCount
;
#else
std
::
string
path_utf8
=
stringWstingToUtf8String
(
path
.
c_str
());
std
::
vector
<
std
::
string
>
files
;
listdir
(
path_utf8
.
c_str
(),
recursive
,
files
);
return
files
.
size
()
+
1
;
return
arrFiles
.
GetCount
();
#endif
return
arrFiles
.
GetCount
()
+
1
;
// ???
}
#if !defined(_WIN32) && !defined (_WIN64)
static
bool
PathIsDirectory
(
const
std
::
wstring
&
pathName
)
{
struct
stat
s
;
std
::
string
sPathNameUtf8
=
stringWstingToUtf8String
(
pathName
);
if
(
stat
(
sPathNameUtf8
.
c_str
(),
&
s
)
==
0
)
{
if
(
s
.
st_mode
&
S_IFDIR
)
return
true
;
else
return
false
;
}
return
false
;
return
Exists
(
pathName
);
}
#endif
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment