Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Larry Price
gmsh
Commits
d2292481
Commit
d2292481
authored
11 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
simpler
parent
7c3ed518
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Common/OS.cpp
+20
-31
20 additions, 31 deletions
Common/OS.cpp
with
20 additions
and
31 deletions
Common/OS.cpp
+
20
−
31
View file @
d2292481
...
@@ -139,25 +139,26 @@ static unsigned utf8toUtf16(const char* src, unsigned srclen,
...
@@ -139,25 +139,26 @@ static unsigned utf8toUtf16(const char* src, unsigned srclen,
return
count
;
return
count
;
}
}
static
wchar_t
*
wbuf
=
NULL
;
static
wchar_t
*
wbuf
[
2
]
=
{
NULL
,
NULL
};
static
wchar_t
*
wbuf1
=
NULL
;
static
void
setwbuf
(
int
i
,
const
char
*
f
)
{
if
(
i
!=
0
||
i
!=
1
)
return
;
size_t
l
=
strlen
(
f
);
unsigned
wn
=
utf8toUtf16
(
f
,
(
unsigned
)
l
,
NULL
,
0
)
+
1
;
wbuf
[
i
]
=
(
wchar_t
*
)
realloc
(
wbuf
[
i
],
sizeof
(
wchar_t
)
*
wn
);
wn
=
utf8toUtf16
(
f
,
(
unsigned
)
l
,
(
unsigned
short
*
)
wbuf
[
i
],
wn
);
wbuf
[
i
][
wn
]
=
0
;
}
#endif
#endif
FILE
*
Fopen
(
const
char
*
f
,
const
char
*
mode
)
FILE
*
Fopen
(
const
char
*
f
,
const
char
*
mode
)
{
{
#if defined (WIN32) && !defined(__CYGWIN__)
#if defined (WIN32) && !defined(__CYGWIN__)
size_t
l
=
strlen
(
f
);
setwbuf
(
0
,
f
);
unsigned
wn
=
utf8toUtf16
(
f
,
(
unsigned
)
l
,
NULL
,
0
)
+
1
;
setwbuf
(
1
,
mode
);
wbuf
=
(
wchar_t
*
)
realloc
(
wbuf
,
sizeof
(
wchar_t
)
*
wn
);
return
_wfopen
(
wbuf
[
0
],
wbuf
[
1
]);
wn
=
utf8toUtf16
(
f
,
(
unsigned
)
l
,
(
unsigned
short
*
)
wbuf
,
wn
);
wbuf
[
wn
]
=
0
;
l
=
strlen
(
mode
);
wn
=
utf8toUtf16
(
mode
,
(
unsigned
)
l
,
NULL
,
0
)
+
1
;
wbuf1
=
(
wchar_t
*
)
realloc
(
wbuf1
,
sizeof
(
wchar_t
)
*
wn
);
wn
=
utf8toUtf16
(
mode
,
(
unsigned
)
l
,
(
unsigned
short
*
)
wbuf1
,
wn
);
wbuf1
[
wn
]
=
0
;
return
_wfopen
(
wbuf
,
wbuf1
);
#else
#else
return
fopen
(
f
,
mode
);
return
fopen
(
f
,
mode
);
#endif
#endif
...
@@ -288,12 +289,8 @@ std::string GetHostName()
...
@@ -288,12 +289,8 @@ std::string GetHostName()
int
UnlinkFile
(
const
std
::
string
&
fileName
)
int
UnlinkFile
(
const
std
::
string
&
fileName
)
{
{
#if defined(WIN32) && !defined(__CYGWIN__)
#if defined(WIN32) && !defined(__CYGWIN__)
size_t
l
=
strlen
(
fileName
.
c_str
());
setwbuf
(
0
,
fileName
.
c_str
());
unsigned
wn
=
utf8toUtf16
(
fileName
.
c_str
(),
(
unsigned
)
l
,
NULL
,
0
)
+
1
;
return
_wunlink
(
wbuf
[
0
]);
wbuf
=
(
wchar_t
*
)
realloc
(
wbuf
,
sizeof
(
wchar_t
)
*
wn
);
wn
=
utf8toUtf16
(
fileName
.
c_str
(),
(
unsigned
)
l
,
(
unsigned
short
*
)
wbuf
,
wn
);
wbuf
[
wn
]
=
0
;
return
_wunlink
(
wbuf
);
#else
#else
return
unlink
(
fileName
.
c_str
());
return
unlink
(
fileName
.
c_str
());
#endif
#endif
...
@@ -303,12 +300,8 @@ int StatFile(const std::string &fileName)
...
@@ -303,12 +300,8 @@ int StatFile(const std::string &fileName)
{
{
#if defined(WIN32) && !defined(__CYGWIN__)
#if defined(WIN32) && !defined(__CYGWIN__)
struct
_stat
buf
;
struct
_stat
buf
;
size_t
l
=
strlen
(
fileName
.
c_str
());
setwbuf
(
0
,
fileName
.
c_str
());
unsigned
wn
=
utf8toUtf16
(
fileName
.
c_str
(),
(
unsigned
)
l
,
NULL
,
0
)
+
1
;
int
ret
=
_wstat
(
wbuf
[
0
],
&
buf
);
wbuf
=
(
wchar_t
*
)
realloc
(
wbuf
,
sizeof
(
wchar_t
)
*
wn
);
wn
=
utf8toUtf16
(
fileName
.
c_str
(),
(
unsigned
)
l
,
(
unsigned
short
*
)
wbuf
,
wn
);
wbuf
[
wn
]
=
0
;
int
ret
=
_wstat
(
wbuf
,
&
buf
);
#else
#else
struct
stat
buf
;
struct
stat
buf
;
int
ret
=
stat
(
fileName
.
c_str
(),
&
buf
);
int
ret
=
stat
(
fileName
.
c_str
(),
&
buf
);
...
@@ -319,12 +312,8 @@ int StatFile(const std::string &fileName)
...
@@ -319,12 +312,8 @@ int StatFile(const std::string &fileName)
int
CreateDirectory
(
const
std
::
string
&
dirName
)
int
CreateDirectory
(
const
std
::
string
&
dirName
)
{
{
#if defined(WIN32) && !defined(__CYGWIN__)
#if defined(WIN32) && !defined(__CYGWIN__)
size_t
l
=
strlen
(
dirName
.
c_str
());
setwbuf
(
0
,
dirName
.
c_str
());
unsigned
wn
=
utf8toUtf16
(
dirName
.
c_str
(),
(
unsigned
)
l
,
NULL
,
0
)
+
1
;
if
(
_wmkdir
(
wbuf
[
0
]))
return
0
;
wbuf
=
(
wchar_t
*
)
realloc
(
wbuf
,
sizeof
(
wchar_t
)
*
wn
);
wn
=
utf8toUtf16
(
dirName
.
c_str
(),
(
unsigned
)
l
,
(
unsigned
short
*
)
wbuf
,
wn
);
wbuf
[
wn
]
=
0
;
if
(
_wmkdir
(
wbuf
))
return
0
;
#else
#else
if
(
mkdir
(
dirName
.
c_str
(),
0777
))
return
0
;
if
(
mkdir
(
dirName
.
c_str
(),
0777
))
return
0
;
#endif
#endif
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment