mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
add Filename::is_binary_or_text()
This commit is contained in:
parent
24acb72bb4
commit
5fd6d60f40
@ -381,6 +381,19 @@ is_binary() const {
|
|||||||
return ((_flags & F_binary) != 0);
|
return ((_flags & F_binary) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: Filename::is_binary_or_text
|
||||||
|
// Access: Published
|
||||||
|
// Description: Returns true either is_binary() or is_text() is true;
|
||||||
|
// that is, that the filename has been specified as
|
||||||
|
// either binary or text. If this is false, the
|
||||||
|
// filename has not been specified.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE bool Filename::
|
||||||
|
is_binary_or_text() const {
|
||||||
|
return ((_flags & (F_binary | F_text)) != 0);
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: Filename::is_text
|
// Function: Filename::is_text
|
||||||
// Access: Published
|
// Access: Published
|
||||||
|
@ -1069,7 +1069,9 @@ make_canonical() {
|
|||||||
// Use realpath in order to resolve symlinks properly
|
// Use realpath in order to resolve symlinks properly
|
||||||
char newpath [PATH_MAX + 1];
|
char newpath [PATH_MAX + 1];
|
||||||
if (realpath(c_str(), newpath) != NULL) {
|
if (realpath(c_str(), newpath) != NULL) {
|
||||||
(*this) = newpath;
|
Filename newpath_fn(newpath);
|
||||||
|
newpath_fn._flags = _flags;
|
||||||
|
(*this) = newpath_fn;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1151,6 +1153,7 @@ make_true_case() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
true_case._flags = _flags;
|
||||||
(*this) = true_case;
|
(*this) = true_case;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -1935,7 +1938,7 @@ scan_directory() const {
|
|||||||
bool Filename::
|
bool Filename::
|
||||||
open_read(ifstream &stream) const {
|
open_read(ifstream &stream) const {
|
||||||
assert(!get_pattern());
|
assert(!get_pattern());
|
||||||
assert(is_text() || is_binary());
|
assert(is_binary_or_text());
|
||||||
|
|
||||||
ios_openmode open_mode = ios::in;
|
ios_openmode open_mode = ios::in;
|
||||||
|
|
||||||
@ -1971,7 +1974,7 @@ open_read(ifstream &stream) const {
|
|||||||
bool Filename::
|
bool Filename::
|
||||||
open_write(ofstream &stream, bool truncate) const {
|
open_write(ofstream &stream, bool truncate) const {
|
||||||
assert(!get_pattern());
|
assert(!get_pattern());
|
||||||
assert(is_text() || is_binary());
|
assert(is_binary_or_text());
|
||||||
|
|
||||||
ios_openmode open_mode = ios::out;
|
ios_openmode open_mode = ios::out;
|
||||||
|
|
||||||
@ -2022,7 +2025,7 @@ open_write(ofstream &stream, bool truncate) const {
|
|||||||
bool Filename::
|
bool Filename::
|
||||||
open_append(ofstream &stream) const {
|
open_append(ofstream &stream) const {
|
||||||
assert(!get_pattern());
|
assert(!get_pattern());
|
||||||
assert(is_text() || is_binary());
|
assert(is_binary_or_text());
|
||||||
|
|
||||||
ios_openmode open_mode = ios::app;
|
ios_openmode open_mode = ios::app;
|
||||||
|
|
||||||
@ -2059,7 +2062,7 @@ open_append(ofstream &stream) const {
|
|||||||
bool Filename::
|
bool Filename::
|
||||||
open_read_write(fstream &stream, bool truncate) const {
|
open_read_write(fstream &stream, bool truncate) const {
|
||||||
assert(!get_pattern());
|
assert(!get_pattern());
|
||||||
assert(is_text() || is_binary());
|
assert(is_binary_or_text());
|
||||||
|
|
||||||
ios_openmode open_mode = ios::out | ios::in;
|
ios_openmode open_mode = ios::out | ios::in;
|
||||||
|
|
||||||
@ -2107,7 +2110,7 @@ open_read_write(fstream &stream, bool truncate) const {
|
|||||||
bool Filename::
|
bool Filename::
|
||||||
open_read_append(fstream &stream) const {
|
open_read_append(fstream &stream) const {
|
||||||
assert(!get_pattern());
|
assert(!get_pattern());
|
||||||
assert(is_text() || is_binary());
|
assert(is_binary_or_text());
|
||||||
|
|
||||||
ios_openmode open_mode = ios::app | ios::in;
|
ios_openmode open_mode = ios::app | ios::in;
|
||||||
|
|
||||||
@ -2145,7 +2148,7 @@ open_read_append(fstream &stream) const {
|
|||||||
bool Filename::
|
bool Filename::
|
||||||
open_read(pifstream &stream) const {
|
open_read(pifstream &stream) const {
|
||||||
assert(!get_pattern());
|
assert(!get_pattern());
|
||||||
assert(is_text() || is_binary());
|
assert(is_binary_or_text());
|
||||||
|
|
||||||
ios_openmode open_mode = ios::in;
|
ios_openmode open_mode = ios::in;
|
||||||
|
|
||||||
@ -2183,7 +2186,7 @@ open_read(pifstream &stream) const {
|
|||||||
bool Filename::
|
bool Filename::
|
||||||
open_write(pofstream &stream, bool truncate) const {
|
open_write(pofstream &stream, bool truncate) const {
|
||||||
assert(!get_pattern());
|
assert(!get_pattern());
|
||||||
assert(is_text() || is_binary());
|
assert(is_binary_or_text());
|
||||||
|
|
||||||
ios_openmode open_mode = ios::out;
|
ios_openmode open_mode = ios::out;
|
||||||
|
|
||||||
@ -2236,7 +2239,7 @@ open_write(pofstream &stream, bool truncate) const {
|
|||||||
bool Filename::
|
bool Filename::
|
||||||
open_append(pofstream &stream) const {
|
open_append(pofstream &stream) const {
|
||||||
assert(!get_pattern());
|
assert(!get_pattern());
|
||||||
assert(is_text() || is_binary());
|
assert(is_binary_or_text());
|
||||||
|
|
||||||
ios_openmode open_mode = ios::app;
|
ios_openmode open_mode = ios::app;
|
||||||
|
|
||||||
@ -2275,7 +2278,7 @@ open_append(pofstream &stream) const {
|
|||||||
bool Filename::
|
bool Filename::
|
||||||
open_read_write(pfstream &stream, bool truncate) const {
|
open_read_write(pfstream &stream, bool truncate) const {
|
||||||
assert(!get_pattern());
|
assert(!get_pattern());
|
||||||
assert(is_text() || is_binary());
|
assert(is_binary_or_text());
|
||||||
|
|
||||||
ios_openmode open_mode = ios::out | ios::in;
|
ios_openmode open_mode = ios::out | ios::in;
|
||||||
|
|
||||||
@ -2325,7 +2328,7 @@ open_read_write(pfstream &stream, bool truncate) const {
|
|||||||
bool Filename::
|
bool Filename::
|
||||||
open_read_append(pfstream &stream) const {
|
open_read_append(pfstream &stream) const {
|
||||||
assert(!get_pattern());
|
assert(!get_pattern());
|
||||||
assert(is_text() || is_binary());
|
assert(is_binary_or_text());
|
||||||
|
|
||||||
ios_openmode open_mode = ios::app | ios::in;
|
ios_openmode open_mode = ios::app | ios::in;
|
||||||
|
|
||||||
@ -2530,7 +2533,9 @@ rename_to(const Filename &other) const {
|
|||||||
// Access: Published
|
// Access: Published
|
||||||
// Description: Copies the file to the indicated new filename, by
|
// Description: Copies the file to the indicated new filename, by
|
||||||
// reading the contents and writing it to the new file.
|
// reading the contents and writing it to the new file.
|
||||||
// Returns true if successful, false on failure.
|
// Returns true if successful, false on failure. The
|
||||||
|
// copy is always binary, regardless of the filename
|
||||||
|
// settings.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
bool Filename::
|
bool Filename::
|
||||||
copy_to(const Filename &other) const {
|
copy_to(const Filename &other) const {
|
||||||
|
@ -133,6 +133,7 @@ PUBLISHED:
|
|||||||
INLINE void set_text();
|
INLINE void set_text();
|
||||||
INLINE bool is_binary() const;
|
INLINE bool is_binary() const;
|
||||||
INLINE bool is_text() const;
|
INLINE bool is_text() const;
|
||||||
|
INLINE bool is_binary_or_text() const;
|
||||||
|
|
||||||
INLINE void set_type(Type type);
|
INLINE void set_type(Type type);
|
||||||
INLINE Type get_type() const;
|
INLINE Type get_type() const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user