mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 08:44:19 -04:00
*** empty log message ***
This commit is contained in:
parent
80dd7df542
commit
6680092c52
@ -1,10 +1,10 @@
|
||||
#begin lib_target
|
||||
#begin ss_lib_target
|
||||
#define TARGET cvscopy
|
||||
#define LOCAL_LIBS \
|
||||
progbase pandatoolbase
|
||||
|
||||
#define OTHER_LIBS \
|
||||
dconfig:c dtool:m
|
||||
linmath:c panda:m dconfig:c dtool:m pystub
|
||||
|
||||
#define SOURCES \
|
||||
cvsCopy.cxx cvsCopy.h cvsSourceDirectory.cxx cvsSourceDirectory.h \
|
||||
@ -13,7 +13,7 @@
|
||||
#define INSTALL_HEADERS \
|
||||
cvsCopy.h
|
||||
|
||||
#end lib_target
|
||||
#end ss_lib_target
|
||||
|
||||
#begin test_bin_target
|
||||
#define TARGET testcopy
|
||||
|
@ -15,6 +15,10 @@
|
||||
#include <stdio.h> // for perror
|
||||
#include <errno.h>
|
||||
|
||||
#if defined(WIN32_VC)
|
||||
#include <direct.h>
|
||||
#endif
|
||||
|
||||
bool CVSSourceTree::_got_start_fullpath = false;
|
||||
string CVSSourceTree::_start_fullpath;
|
||||
|
||||
|
@ -20,13 +20,21 @@
|
||||
#include <set>
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifdef WIN32_VC
|
||||
#include <io.h>
|
||||
#include <share.h>
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
AttribFile::
|
||||
AttribFile(const Filename &filename) {
|
||||
_name = filename.get_basename_wo_extension();
|
||||
_txa_filename = filename;
|
||||
_txa_filename.set_extension("txa");
|
||||
_txa_filename.set_text();
|
||||
_pi_filename = filename;
|
||||
_pi_filename.set_extension("pi");
|
||||
_pi_filename.set_text();
|
||||
_txa_fd = -1;
|
||||
|
||||
|
||||
@ -58,7 +66,34 @@ open_and_lock(bool lock) {
|
||||
nout << "Attributes file " << _txa_filename << " does not exist.\n";
|
||||
}
|
||||
|
||||
#ifdef WIN32_VC
|
||||
if (lock) {
|
||||
nout << "File locking unimplemented on Windows. Specify -nolock.\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
_txa_fd = _sopen(_txa_filename.c_str(), _O_RDWR | _O_CREAT, _SH_DENYRW,
|
||||
_S_IREAD | _S_IWRITE);
|
||||
|
||||
if (_txa_fd < 0) {
|
||||
perror(_txa_filename.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
_txa_fstrm.attach(_txa_fd);
|
||||
*/
|
||||
|
||||
if (!_txa_filename.open_read_write(_txa_fstrm)) {
|
||||
cerr << "Unable to read " << _txa_filename << "\n";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
#else
|
||||
// Unix-style
|
||||
_txa_fd = open(_txa_filename.c_str(), O_RDWR | O_CREAT, 0666);
|
||||
|
||||
if (_txa_fd < 0) {
|
||||
perror(_txa_filename.c_str());
|
||||
return false;
|
||||
@ -83,6 +118,7 @@ open_and_lock(bool lock) {
|
||||
}
|
||||
|
||||
_txa_fstrm.attach(_txa_fd);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -107,8 +143,8 @@ read(bool force_redo_all) {
|
||||
if (!_pi_filename.exists()) {
|
||||
nout << "Palette information file " << _pi_filename << " does not exist.\n";
|
||||
} else {
|
||||
ifstream infile(_pi_filename.c_str());
|
||||
if (!infile) {
|
||||
ifstream infile;
|
||||
if (!_pi_filename.open_read(infile)) {
|
||||
nout << "Palette information file " << _pi_filename << " exists, but cannot be read.\n";
|
||||
return false;
|
||||
}
|
||||
@ -126,17 +162,23 @@ write() {
|
||||
|
||||
if (_txa_needs_rewrite) {
|
||||
// Rewind and truncate the file for writing.
|
||||
#ifdef WIN32_VC
|
||||
_txa_fstrm.close();
|
||||
_txa_filename.unlink();
|
||||
_txa_filename.open_read_write(_txa_fstrm);
|
||||
#else
|
||||
_txa_fstrm.clear();
|
||||
_txa_fstrm.seekp(0, ios::beg);
|
||||
ftruncate(_txa_fd, 0);
|
||||
#endif
|
||||
|
||||
okflag = write_txa(_txa_fstrm) && okflag;
|
||||
_txa_fstrm << flush;
|
||||
}
|
||||
|
||||
{
|
||||
ofstream outfile(_pi_filename.c_str(), ios::out, 0666);
|
||||
if (!outfile) {
|
||||
ofstream outfile;
|
||||
if (!_pi_filename.open_write(outfile)) {
|
||||
nout << "Unable to write file " << _pi_filename << "\n";
|
||||
return false;
|
||||
}
|
||||
@ -782,7 +824,7 @@ read_pi(istream &infile, bool force_redo_all) {
|
||||
}
|
||||
}
|
||||
|
||||
vector<string> words = extract_words(line);
|
||||
vector_string words = extract_words(line);
|
||||
bool okflag = true;
|
||||
|
||||
if (words.empty()) {
|
||||
@ -942,7 +984,7 @@ write_pi(ostream &out) const {
|
||||
}
|
||||
|
||||
bool AttribFile::
|
||||
parse_params(const vector<string> &words, istream &infile,
|
||||
parse_params(const vector_string &words, istream &infile,
|
||||
string &line, int &line_num) {
|
||||
if (words.size() != 1) {
|
||||
nout << "Unexpected keywords on line.\n";
|
||||
@ -967,9 +1009,9 @@ parse_params(const vector<string> &words, istream &infile,
|
||||
} else if (param == "default_margin") {
|
||||
_default_margin = atoi(value.c_str());
|
||||
} else if (param == "force_power_2") {
|
||||
_force_power_2 = atoi(value.c_str());
|
||||
_force_power_2 = (atoi(value.c_str()) != 0);
|
||||
} else if (param == "aggressively_clean_mapdir") {
|
||||
_aggressively_clean_mapdir = atoi(value.c_str());
|
||||
_aggressively_clean_mapdir = (atoi(value.c_str()) != 0);
|
||||
} else {
|
||||
nout << "Unexpected keyword: " << param << "\n";
|
||||
return false;
|
||||
@ -984,7 +1026,7 @@ parse_params(const vector<string> &words, istream &infile,
|
||||
}
|
||||
|
||||
bool AttribFile::
|
||||
parse_packing(const vector<string> &words, istream &infile,
|
||||
parse_packing(const vector_string &words, istream &infile,
|
||||
string &line, int &line_num) {
|
||||
if (!(words.size() == 3 && words[1] == "is" &&
|
||||
(words[2] == "optimal" || words[2] == "suboptimal"))) {
|
||||
@ -1001,7 +1043,7 @@ parse_packing(const vector<string> &words, istream &infile,
|
||||
|
||||
|
||||
bool AttribFile::
|
||||
parse_texture(const vector<string> &words, istream &infile,
|
||||
parse_texture(const vector_string &words, istream &infile,
|
||||
string &line, int &line_num) {
|
||||
if (words.size() != 1) {
|
||||
nout << "Unexpected words on line.\n";
|
||||
@ -1012,7 +1054,7 @@ parse_texture(const vector<string> &words, istream &infile,
|
||||
line = trim_right(line);
|
||||
line_num++;
|
||||
while (!infile.eof() && !line.empty() && isspace(line[0])) {
|
||||
vector<string> twords = extract_words(line);
|
||||
vector_string twords = extract_words(line);
|
||||
if (twords.size() < 1) {
|
||||
nout << "Expected texture name and additional parameters.\n";
|
||||
return false;
|
||||
@ -1050,7 +1092,7 @@ parse_texture(const vector<string> &words, istream &infile,
|
||||
}
|
||||
|
||||
bool AttribFile::
|
||||
parse_pathname(const vector<string> &words, istream &infile,
|
||||
parse_pathname(const vector_string &words, istream &infile,
|
||||
string &line, int &line_num) {
|
||||
if (words.size() != 1) {
|
||||
nout << "Unexpected words on line.\n";
|
||||
@ -1063,7 +1105,7 @@ parse_pathname(const vector<string> &words, istream &infile,
|
||||
PTexture *texture = NULL;
|
||||
|
||||
while (!infile.eof() && !line.empty() && isspace(line[0])) {
|
||||
vector<string> twords = extract_words(line);
|
||||
vector_string twords = extract_words(line);
|
||||
if (twords.size() == 1) {
|
||||
// Only one word on the line means it's an alternate filename
|
||||
// for the previous texture.
|
||||
@ -1093,7 +1135,7 @@ parse_pathname(const vector<string> &words, istream &infile,
|
||||
}
|
||||
|
||||
bool AttribFile::
|
||||
parse_egg(const vector<string> &words, istream &infile,
|
||||
parse_egg(const vector_string &words, istream &infile,
|
||||
string &line, int &line_num, bool force_redo_all) {
|
||||
if (words.size() < 2) {
|
||||
nout << "Egg filename expected.\n";
|
||||
@ -1113,7 +1155,7 @@ parse_egg(const vector<string> &words, istream &infile,
|
||||
line = trim_right(line);
|
||||
line_num++;
|
||||
while (!infile.eof() && !line.empty() && isspace(line[0])) {
|
||||
vector<string> twords = extract_words(line);
|
||||
vector_string twords = extract_words(line);
|
||||
if (twords.size() < 1) {
|
||||
nout << "Expected texture name\n";
|
||||
return false;
|
||||
@ -1168,7 +1210,7 @@ parse_egg(const vector<string> &words, istream &infile,
|
||||
|
||||
|
||||
bool AttribFile::
|
||||
parse_group(const vector<string> &words, istream &infile,
|
||||
parse_group(const vector_string &words, istream &infile,
|
||||
string &line, int &line_num) {
|
||||
if (words.size() == 2) {
|
||||
// Just a group name by itself; ignore it.
|
||||
@ -1194,7 +1236,7 @@ parse_group(const vector<string> &words, istream &infile,
|
||||
}
|
||||
|
||||
bool AttribFile::
|
||||
parse_palette(const vector<string> &words, istream &infile,
|
||||
parse_palette(const vector_string &words, istream &infile,
|
||||
string &line, int &line_num) {
|
||||
if (words.size() != 8) {
|
||||
nout << "Palette filename, group, size, and number of components expected.\n";
|
||||
@ -1224,7 +1266,7 @@ parse_palette(const vector<string> &words, istream &infile,
|
||||
line = trim_right(line);
|
||||
line_num++;
|
||||
while (!infile.eof() && !line.empty() && isspace(line[0])) {
|
||||
vector<string> twords = extract_words(line);
|
||||
vector_string twords = extract_words(line);
|
||||
if (twords.size() != 9) {
|
||||
nout << "Expected texture placement line.\n";
|
||||
return false;
|
||||
@ -1266,7 +1308,7 @@ parse_palette(const vector<string> &words, istream &infile,
|
||||
|
||||
|
||||
bool AttribFile::
|
||||
parse_unplaced(const vector<string> &words, istream &infile,
|
||||
parse_unplaced(const vector_string &words, istream &infile,
|
||||
string &line, int &line_num) {
|
||||
if (words.size() != 6) {
|
||||
nout << "Unplaced texture description expected.\n";
|
||||
@ -1311,7 +1353,7 @@ parse_unplaced(const vector<string> &words, istream &infile,
|
||||
}
|
||||
|
||||
bool AttribFile::
|
||||
parse_surprises(const vector<string> &words, istream &infile,
|
||||
parse_surprises(const vector_string &words, istream &infile,
|
||||
string &line, int &line_num) {
|
||||
if (words.size() != 1) {
|
||||
nout << "Unexpected words on line.\n";
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <pandatoolbase.h>
|
||||
|
||||
#include <filename.h>
|
||||
#include <vector_string.h>
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
@ -97,23 +98,23 @@ private:
|
||||
bool write_txa(ostream &outfile) const;
|
||||
bool write_pi(ostream &outfile) const;
|
||||
|
||||
bool parse_params(const vector<string> &words, istream &infile,
|
||||
bool parse_params(const vector_string &words, istream &infile,
|
||||
string &line, int &line_num);
|
||||
bool parse_packing(const vector<string> &words, istream &infile,
|
||||
bool parse_packing(const vector_string &words, istream &infile,
|
||||
string &line, int &line_num);
|
||||
bool parse_texture(const vector<string> &words, istream &infile,
|
||||
bool parse_texture(const vector_string &words, istream &infile,
|
||||
string &line, int &line_num);
|
||||
bool parse_pathname(const vector<string> &words, istream &infile,
|
||||
bool parse_pathname(const vector_string &words, istream &infile,
|
||||
string &line, int &line_num);
|
||||
bool parse_egg(const vector<string> &words, istream &infile,
|
||||
bool parse_egg(const vector_string &words, istream &infile,
|
||||
string &line, int &line_num, bool force_redo_all);
|
||||
bool parse_group(const vector<string> &words, istream &infile,
|
||||
bool parse_group(const vector_string &words, istream &infile,
|
||||
string &line, int &line_num);
|
||||
bool parse_palette(const vector<string> &words, istream &infile,
|
||||
bool parse_palette(const vector_string &words, istream &infile,
|
||||
string &line, int &line_num);
|
||||
bool parse_unplaced(const vector<string> &words, istream &infile,
|
||||
bool parse_unplaced(const vector_string &words, istream &infile,
|
||||
string &line, int &line_num);
|
||||
bool parse_surprises(const vector<string> &words, istream &infile,
|
||||
bool parse_surprises(const vector_string &words, istream &infile,
|
||||
string &line, int &line_num);
|
||||
|
||||
bool _optimal;
|
||||
|
@ -27,9 +27,9 @@ trim_right(const string &str) {
|
||||
return str.substr(begin, end - begin);
|
||||
}
|
||||
|
||||
vector<string>
|
||||
vector_string
|
||||
extract_words(const string &str) {
|
||||
vector<string> result;
|
||||
vector_string result;
|
||||
|
||||
size_t pos = 0;
|
||||
while (pos < str.length() && isspace(str[pos])) {
|
||||
|
@ -7,13 +7,14 @@
|
||||
#define STRING_UTILS_H
|
||||
|
||||
#include <pandatoolbase.h>
|
||||
#include <vector_string.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
string trim_left(const string &str);
|
||||
string trim_right(const string &str);
|
||||
|
||||
vector<string> extract_words(const string &str);
|
||||
vector_string extract_words(const string &str);
|
||||
void extract_param_value(const string &str, string ¶m, string &value);
|
||||
|
||||
#endif
|
||||
|
@ -316,7 +316,7 @@ list_names(ostream &out) const {
|
||||
|
||||
bool UserAttribLine::
|
||||
keyword_line(const string &line) {
|
||||
vector<string> words = extract_words(line);
|
||||
vector_string words = extract_words(line);
|
||||
assert(!words.empty());
|
||||
|
||||
if (words[0] == ":margin") {
|
||||
@ -391,10 +391,10 @@ texture_line(const string &line) {
|
||||
}
|
||||
|
||||
// Split the line into two parts at the colon.
|
||||
vector<string> names = extract_words(line.substr(0, colon));
|
||||
vector<string> params = extract_words(line.substr(colon + 2));
|
||||
vector_string names = extract_words(line.substr(0, colon));
|
||||
vector_string params = extract_words(line.substr(colon + 2));
|
||||
|
||||
vector<string>::const_iterator ni;
|
||||
vector_string::const_iterator ni;
|
||||
for (ni = names.begin(); ni != names.end(); ++ni) {
|
||||
_patterns.push_back(GlobPattern(*ni));
|
||||
}
|
||||
@ -467,7 +467,7 @@ texture_line(const string &line) {
|
||||
|
||||
bool UserAttribLine::
|
||||
old_style_line(const string &line) {
|
||||
vector<string> words = extract_words(line);
|
||||
vector_string words = extract_words(line);
|
||||
assert(!words.empty());
|
||||
|
||||
if (words.size() != 3 && words.size() != 4) {
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <pandatoolbase.h>
|
||||
|
||||
#include <globPattern.h>
|
||||
#include <vector_string.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
@ -63,7 +64,7 @@ private:
|
||||
|
||||
typedef vector<GlobPattern> Patterns;
|
||||
Patterns _patterns;
|
||||
typedef vector<string> Names;
|
||||
typedef vector_string Names;
|
||||
Names _names;
|
||||
|
||||
ostream &list_patterns(ostream &out) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user