Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2933)

Unified Diff: runtime/bin/file.h

Issue 9034005: Change the behavior of open on files to not truncate by default (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comment.s Created 8 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/dartutils.cc ('k') | runtime/bin/file.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/file.h
diff --git a/runtime/bin/file.h b/runtime/bin/file.h
index 239544774e7c33de3ae2983e39d7881a8978f86d..b4e78d8224d44e43919ea452333cd45835ea573e 100644
--- a/runtime/bin/file.h
+++ b/runtime/bin/file.h
@@ -22,6 +22,13 @@ class FileHandle;
class File {
public:
+ enum FileOpenMode {
+ kRead = 0,
+ kWrite = 1,
+ kTruncate = 1 << 2,
+ kWriteTruncate = kWrite | kTruncate
+ };
+
~File();
// Read/Write attempt to transfer num_bytes to/from buffer. It returns
@@ -58,7 +65,13 @@ class File {
const char* name() const { return name_; }
- static File* Open(const char* name, bool writable);
+ // Open the file with the given name. The file is always opened for
+ // reading. If mode contains kWrite the file is opened for both
+ // reading and writing. If mode contains kWrite and the file does
+ // not exist the file is created. The file is truncated to length 0 if
+ // mode contains kTruncate.
+ static File* Open(const char* name, FileOpenMode mode);
+
static bool Exists(const char* name);
static bool Create(const char* name);
static bool Delete(const char* name);
« no previous file with comments | « runtime/bin/dartutils.cc ('k') | runtime/bin/file.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698