*** empty log message ***

This commit is contained in:
David Rose 2000-11-09 21:42:59 +00:00
parent 5e2c066e84
commit 358caa7860
6 changed files with 92 additions and 13 deletions

View File

@ -118,18 +118,24 @@ import(const Filename &source, void *extra_data,
_tree.choose_directory(basename, suggested_dir, _force, _interactive);
nassertr(dir != (CVSSourceDirectory *)NULL, dir);
nout << "Copying " << basename << " to " << dir->get_path() << "\n";
_copied_files[source] = dir;
Filename dest = dir->get_fullpath() + "/" + basename;
_copied_files[source] = dir;
bool new_file = !dest.exists();
if (!copy_file(source, dest, dir, extra_data, new_file)) {
return (CVSSourceDirectory *)NULL;
}
if (new_file) {
create_file(dest);
if (!new_file && verify_file(source, dest, dir, extra_data)) {
// The file is unchanged.
nout << dir->get_path() + "/" + basename << " is unchanged.\n";
} 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;
@ -200,6 +206,67 @@ post_command_line() {
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
// Access: Protected

View File

@ -32,10 +32,14 @@ protected:
virtual bool handle_args(Args &args);
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,
CVSSourceDirectory *dest_dir,
void *extra_data, bool new_file)=0;
bool verify_binary_file(Filename source, Filename dest);
bool copy_binary_file(Filename source, Filename dest);
bool create_file(const Filename &filename);

View File

@ -396,8 +396,8 @@ ask_existing(const string &filename, const CVSSourceTree::Directories &dirs,
CVSSourceDirectory *CVSSourceTree::
ask_new(const string &filename, CVSSourceDirectory *dir) {
while (true) {
nout << filename << " will be created at "
<< dir->get_path() + "/" + filename << ".\n";
nout << filename << " will be created in "
<< dir->get_path() << ".\n";
string result = prompt("Create this file (y/n)? ");
nassertr(!result.empty(), (CVSSourceDirectory *)NULL);
if (result.size() == 1) {

View File

@ -143,6 +143,13 @@ EggPalettize() : EggMultiFilter(true) {
"which is an integer power of 2. They will be scaled down to "
"achieve this.",
&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
("k", "", 0,
"Kill lines from the attributes file that aren't used on any "
@ -555,7 +562,7 @@ run() {
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
// fatal error.
exit(1);

View File

@ -66,6 +66,7 @@ public:
bool _optimal_resize;
bool _touch_eggs;
bool _eggs_include_images;
bool _dont_lock_pi;
bool _remove_unused_lines;
bool _describe_input_file;

View File

@ -68,7 +68,7 @@ run() {
////////////////////////////////////////////////////////////////////
// Function: FltCopy::copy_file
// 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
// of a file from source to destination. If new_file is
// true, then dest does not already exist.