mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-29 16:20:11 -04:00
*** empty log message ***
This commit is contained in:
parent
5e2c066e84
commit
358caa7860
@ -118,18 +118,24 @@ import(const Filename &source, void *extra_data,
|
|||||||
_tree.choose_directory(basename, suggested_dir, _force, _interactive);
|
_tree.choose_directory(basename, suggested_dir, _force, _interactive);
|
||||||
nassertr(dir != (CVSSourceDirectory *)NULL, dir);
|
nassertr(dir != (CVSSourceDirectory *)NULL, dir);
|
||||||
|
|
||||||
nout << "Copying " << basename << " to " << dir->get_path() << "\n";
|
_copied_files[source] = dir;
|
||||||
|
|
||||||
Filename dest = dir->get_fullpath() + "/" + basename;
|
Filename dest = dir->get_fullpath() + "/" + basename;
|
||||||
|
|
||||||
_copied_files[source] = dir;
|
|
||||||
|
|
||||||
bool new_file = !dest.exists();
|
bool new_file = !dest.exists();
|
||||||
if (!copy_file(source, dest, dir, extra_data, new_file)) {
|
if (!new_file && verify_file(source, dest, dir, extra_data)) {
|
||||||
return (CVSSourceDirectory *)NULL;
|
// The file is unchanged.
|
||||||
}
|
nout << dir->get_path() + "/" + basename << " is unchanged.\n";
|
||||||
if (new_file) {
|
|
||||||
create_file(dest);
|
} else {
|
||||||
|
// The file has changed.
|
||||||
|
nout << "Copying " << basename << " to " << dir->get_path() << "\n";
|
||||||
|
|
||||||
|
if (!copy_file(source, dest, dir, extra_data, new_file)) {
|
||||||
|
return (CVSSourceDirectory *)NULL;
|
||||||
|
}
|
||||||
|
if (new_file) {
|
||||||
|
create_file(dest);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return dir;
|
return dir;
|
||||||
@ -200,6 +206,67 @@ post_command_line() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: CVSCopy::verify_file
|
||||||
|
// Access: Protected, Virtual
|
||||||
|
// Description: Verifies that the file is identical and does not need
|
||||||
|
// to be recopied. Returns true if the files are
|
||||||
|
// identical, false if they differ.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
bool CVSCopy::
|
||||||
|
verify_file(const Filename &, const Filename &,
|
||||||
|
CVSSourceDirectory *, void *) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: CVSCopy::verify_binary_file
|
||||||
|
// Access: Protected
|
||||||
|
// Description: Verifies that the file is identical and does not need
|
||||||
|
// to be recopied. Returns true if the files are
|
||||||
|
// identical, false if they differ.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
bool CVSCopy::
|
||||||
|
verify_binary_file(Filename source, Filename dest) {
|
||||||
|
source.set_binary();
|
||||||
|
dest.set_binary();
|
||||||
|
|
||||||
|
ifstream s, d;
|
||||||
|
if (!source.open_read(s)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!dest.open_read(d)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int cs, cd;
|
||||||
|
cs = s.get();
|
||||||
|
cd = d.get();
|
||||||
|
while (!s.eof() && !s.fail() && !d.eof() && !d.fail()) {
|
||||||
|
if (cs != cd) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
cs = s.get();
|
||||||
|
cd = d.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s.fail() || d.fail()) {
|
||||||
|
// If we had some read error, call the files different.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we haven't reached the end of one of the files yet, that file
|
||||||
|
// is longer than the other one, and the files are therefore
|
||||||
|
// different.
|
||||||
|
if (!s.eof() || !d.eof()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, the files are the same.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: CVSCopy::copy_binary_file
|
// Function: CVSCopy::copy_binary_file
|
||||||
// Access: Protected
|
// Access: Protected
|
||||||
|
@ -32,10 +32,14 @@ protected:
|
|||||||
virtual bool handle_args(Args &args);
|
virtual bool handle_args(Args &args);
|
||||||
virtual bool post_command_line();
|
virtual bool post_command_line();
|
||||||
|
|
||||||
|
virtual bool verify_file(const Filename &source, const Filename &dest,
|
||||||
|
CVSSourceDirectory *dest_dir,
|
||||||
|
void *extra_data);
|
||||||
virtual bool copy_file(const Filename &source, const Filename &dest,
|
virtual bool copy_file(const Filename &source, const Filename &dest,
|
||||||
CVSSourceDirectory *dest_dir,
|
CVSSourceDirectory *dest_dir,
|
||||||
void *extra_data, bool new_file)=0;
|
void *extra_data, bool new_file)=0;
|
||||||
|
|
||||||
|
bool verify_binary_file(Filename source, Filename dest);
|
||||||
bool copy_binary_file(Filename source, Filename dest);
|
bool copy_binary_file(Filename source, Filename dest);
|
||||||
|
|
||||||
bool create_file(const Filename &filename);
|
bool create_file(const Filename &filename);
|
||||||
|
@ -396,8 +396,8 @@ ask_existing(const string &filename, const CVSSourceTree::Directories &dirs,
|
|||||||
CVSSourceDirectory *CVSSourceTree::
|
CVSSourceDirectory *CVSSourceTree::
|
||||||
ask_new(const string &filename, CVSSourceDirectory *dir) {
|
ask_new(const string &filename, CVSSourceDirectory *dir) {
|
||||||
while (true) {
|
while (true) {
|
||||||
nout << filename << " will be created at "
|
nout << filename << " will be created in "
|
||||||
<< dir->get_path() + "/" + filename << ".\n";
|
<< dir->get_path() << ".\n";
|
||||||
string result = prompt("Create this file (y/n)? ");
|
string result = prompt("Create this file (y/n)? ");
|
||||||
nassertr(!result.empty(), (CVSSourceDirectory *)NULL);
|
nassertr(!result.empty(), (CVSSourceDirectory *)NULL);
|
||||||
if (result.size() == 1) {
|
if (result.size() == 1) {
|
||||||
|
@ -143,6 +143,13 @@ EggPalettize() : EggMultiFilter(true) {
|
|||||||
"which is an integer power of 2. They will be scaled down to "
|
"which is an integer power of 2. They will be scaled down to "
|
||||||
"achieve this.",
|
"achieve this.",
|
||||||
&EggPalettize::dispatch_none, &_got_force_power_2);
|
&EggPalettize::dispatch_none, &_got_force_power_2);
|
||||||
|
add_option
|
||||||
|
("nolock", "", 0,
|
||||||
|
"Don't attempt to lock the .pi file before rewriting it. Use "
|
||||||
|
"with extreme caution, as multiple processes running on the same "
|
||||||
|
".pi file may overwrite each other. Use this only if the lock "
|
||||||
|
"cannot be achieved for some reason.",
|
||||||
|
&EggPalettize::dispatch_none, &_dont_lock_pi);
|
||||||
add_option
|
add_option
|
||||||
("k", "", 0,
|
("k", "", 0,
|
||||||
"Kill lines from the attributes file that aren't used on any "
|
"Kill lines from the attributes file that aren't used on any "
|
||||||
@ -555,7 +562,7 @@ run() {
|
|||||||
af.set_default_group(group);
|
af.set_default_group(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!af.grab_lock()) {
|
if (!_dont_lock_pi && !af.grab_lock()) {
|
||||||
// Failing to grab the write lock on the attribute file is a
|
// Failing to grab the write lock on the attribute file is a
|
||||||
// fatal error.
|
// fatal error.
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -66,6 +66,7 @@ public:
|
|||||||
bool _optimal_resize;
|
bool _optimal_resize;
|
||||||
bool _touch_eggs;
|
bool _touch_eggs;
|
||||||
bool _eggs_include_images;
|
bool _eggs_include_images;
|
||||||
|
bool _dont_lock_pi;
|
||||||
bool _remove_unused_lines;
|
bool _remove_unused_lines;
|
||||||
|
|
||||||
bool _describe_input_file;
|
bool _describe_input_file;
|
||||||
|
@ -68,7 +68,7 @@ run() {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: FltCopy::copy_file
|
// Function: FltCopy::copy_file
|
||||||
// Access: Protected, Virtual
|
// Access: Protected, Virtual
|
||||||
// Description: Called by import() if the timestamps indicate that a
|
// Description: Called by import() if verify_file() indicates that a
|
||||||
// file needs to be copied. This does the actual copy
|
// file needs to be copied. This does the actual copy
|
||||||
// of a file from source to destination. If new_file is
|
// of a file from source to destination. If new_file is
|
||||||
// true, then dest does not already exist.
|
// true, then dest does not already exist.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user