Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
d84f96a5
Commit
d84f96a5
authored
Sep 04, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fs/io/FileOutputStream: add mode CREATE_VISIBLE
parent
f600e226
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
5 deletions
+17
-5
FileOutputStream.cxx
src/fs/io/FileOutputStream.cxx
+9
-4
FileOutputStream.hxx
src/fs/io/FileOutputStream.hxx
+8
-1
No files found.
src/fs/io/FileOutputStream.cxx
View file @
d84f96a5
...
...
@@ -26,7 +26,11 @@ FileOutputStream::FileOutputStream(Path _path, Mode _mode)
{
switch
(
mode
)
{
case
Mode
:
:
CREATE
:
OpenCreate
();
OpenCreate
(
false
);
break
;
case
Mode
:
:
CREATE_VISIBLE
:
OpenCreate
(
true
);
break
;
case
Mode
:
:
APPEND_EXISTING
:
...
...
@@ -42,7 +46,7 @@ FileOutputStream::FileOutputStream(Path _path, Mode _mode)
#ifdef WIN32
inline
void
FileOutputStream
::
OpenCreate
()
FileOutputStream
::
OpenCreate
(
gcc_unused
bool
visible
)
{
handle
=
CreateFile
(
path
.
c_str
(),
GENERIC_WRITE
,
0
,
nullptr
,
CREATE_ALWAYS
,
...
...
@@ -147,11 +151,11 @@ OpenTempFile(FileDescriptor &fd, Path path)
#endif
/* HAVE_LINKAT */
inline
void
FileOutputStream
::
OpenCreate
()
FileOutputStream
::
OpenCreate
(
bool
visible
)
{
#ifdef HAVE_LINKAT
/* try Linux's O_TMPFILE first */
is_tmpfile
=
OpenTempFile
(
fd
,
GetPath
());
is_tmpfile
=
!
visible
&&
OpenTempFile
(
fd
,
GetPath
());
if
(
!
is_tmpfile
)
{
#endif
/* fall back to plain POSIX */
...
...
@@ -241,6 +245,7 @@ FileOutputStream::Cancel()
unlink
(
GetPath
().
c_str
());
break
;
case
Mode
:
:
CREATE_VISIBLE
:
case
Mode
:
:
APPEND_EXISTING
:
case
Mode
:
:
APPEND_OR_CREATE
:
/* can't roll this back */
...
...
src/fs/io/FileOutputStream.hxx
View file @
d84f96a5
...
...
@@ -65,6 +65,13 @@ public:
CREATE
,
/**
* Like #CREATE, but no attempt is made to hide file
* contents during the transaction (e.g. via O_TMPFILE
* or a hidden temporary file).
*/
CREATE_VISIBLE
,
/**
* Append to a file that already exists. If it does
* not, an exception is thrown.
*/
...
...
@@ -103,7 +110,7 @@ public:
void
Cancel
();
private
:
void
OpenCreate
();
void
OpenCreate
(
bool
visible
);
void
OpenAppend
(
bool
create
);
bool
Close
()
{
...
...
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