Browse Source

default should be to truncate on open_write

David Rose 23 năm trước cách đây
mục cha
commit
010a35b735
2 tập tin đã thay đổi với 5 bổ sung1 xóa
  1. 4 0
      dtool/src/dtoolutil/filename.cxx
  2. 1 1
      dtool/src/dtoolutil/filename.h

+ 4 - 0
dtool/src/dtoolutil/filename.cxx

@@ -1197,6 +1197,10 @@ open_read(ifstream &stream) const {
 //               appropriately as indicated; it is an error to call
 //               open_read() without first calling one of set_text()
 //               or set_binary().
+//
+//               If truncate is true, the file is truncated to zero
+//               length upon opening it, if it already exists.
+//               Otherwise, the file is kept at its original length.
 ////////////////////////////////////////////////////////////////////
 bool Filename::
 open_write(ofstream &stream, bool truncate) const {

+ 1 - 1
dtool/src/dtoolutil/filename.h

@@ -150,7 +150,7 @@ PUBLISHED:
   bool scan_directory(vector_string &contents) const;
 
   bool open_read(ifstream &stream) const;
-  bool open_write(ofstream &stream, bool truncate = false) const;
+  bool open_write(ofstream &stream, bool truncate = true) const;
   bool open_append(ofstream &stream) const;
   bool open_read_write(fstream &stream) const;