15 #include "softFilename.h" 25 SoftFilename(
const string &dirname,
const string &filename) :
40 size_t dot = _filename.find(
'.');
41 while (dot != string::npos) {
43 const char *fstr = _filename.c_str();
46 int major = strtol(fstr + m , &endptr, 10);
47 if (endptr != fstr + m && *endptr ==
'-') {
49 m = (endptr - fstr) + 1;
50 int minor = strtol(fstr + m, &endptr, 10);
51 if (endptr != fstr + m && (*endptr ==
'.' || *endptr ==
'\0')) {
54 _base = _filename.substr(0, dot + 1);
63 dot = _filename.find(
'.', dot + 1);
74 _dirname(copy._dirname),
75 _filename(copy._filename),
76 _has_version(copy._has_version),
81 _in_cvs(copy._in_cvs),
82 _wants_cvs(copy._wants_cvs),
83 _use_count(copy._use_count)
94 _dirname = copy._dirname;
95 _filename = copy._filename;
96 _has_version = copy._has_version;
101 _in_cvs = copy._in_cvs;
102 _wants_cvs = copy._wants_cvs;
103 _use_count = copy._use_count;
147 nassertr(_has_version,
string());
148 return _base +
"1-0" + _ext;
159 nassertr(_has_version, _filename);
170 nassertr(_has_version, 0);
181 nassertr(_has_version, 0);
193 nassertr(_has_version, _ext);
204 nassertr(_has_version, _filename);
205 nassertr(_ext.length() < _filename.length(), _filename);
206 return _filename.substr(0, _filename.length() - _ext.length());
217 nassertr(_has_version,
false);
218 return (_major == 1 && _minor == 0);
243 return _base == other._base && _ext == other._ext;
257 if (_base != other._base) {
258 return _base < other._base;
261 if (_has_version != other._has_version) {
264 return _has_version < other._has_version;
268 if (_major != other._major) {
269 return _major > other._major;
271 if (_minor != other._minor) {
272 return _minor > other._minor;
309 _wants_cvs = wants_cvs;
string get_1_0_filename() const
Returns what the filename would be if it were version 1-0.
const string & get_dirname() const
Returns the name of the directory this file was found in.
int get_minor() const
Returns the minor version number.
bool is_1_0() const
Returns true if this is a version 1_0 filename, false otherwise.
const string & get_base() const
Returns the base part of the filename.
bool get_wants_cvs() const
Returns true if this file should be entered into the CVS database, false otherwise.
void increment_use_count()
Indicates that this filename is referenced by one more scene file.
bool operator<(const SoftFilename &other) const
Puts filenames in order such that the files with the same base are sorted together, ignoring extension; and within files with the same base, files are sorted in decreasing version number order so that the most recent version appears first.
int get_major() const
Returns the major version number.
int get_use_count() const
Returns the number of scene files that referenced this filename.
const string & get_extension() const
Returns the extension part of the filename.
const string & get_filename() const
Returns the actual filename as found in the directory.
This encapsulates a SoftImage versioned filename, of the form base.v-v.ext: it consists of a director...
void set_in_cvs(bool in_cvs)
Sets the flag that indicates whether this file is known to be entered into the CVS database...
void set_wants_cvs(bool wants_cvs)
Sets the flag that indicates whether this file should be entered into the CVS database.
bool has_version() const
Returns true if the filename had a version number, false otherwise.
void make_1_0()
Makes this a 1_0 filename.
string get_non_extension() const
Returns the filename part, without the extension.
bool is_same_file(const SoftFilename &other) const
Returns true if this file has the same base and extension as the other, disregarding the version numb...
bool get_in_cvs() const
Returns true if this file is known to be entered in the CVS database, false if it is not...