*** empty log message ***

This commit is contained in:
Joe Shochet 2001-04-12 18:33:27 +00:00
parent 6bdce752d7
commit b601b49c80
3 changed files with 89 additions and 86 deletions

View File

@ -85,7 +85,7 @@ get_client_multifile_size(string mfname) const {
INLINE void DownloadDb::
set_client_multifile_size(string mfname, int size) {
(_client_db.get_multifile_record_named(mfname))->_size = size;
write_db(_client_db._filename, _client_db);
write_client_db(_client_db._filename);
}
@ -97,7 +97,7 @@ set_client_multifile_size(string mfname, int size) {
INLINE int DownloadDb::
set_client_multifile_delta_size(string mfname, int size) {
(_client_db.get_multifile_record_named(mfname))->_size += size;
write_db(_client_db._filename, _client_db);
write_client_db(_client_db._filename);
// Return the new total
return (_client_db.get_multifile_record_named(mfname))->_size;
}
@ -134,7 +134,7 @@ set_server_multifile_size(string mfname, int size) {
INLINE void DownloadDb::
set_client_multifile_incomplete(string mfname) {
(_client_db.get_multifile_record_named(mfname))->_status = Status_incomplete;
write_db(_client_db._filename, _client_db);
write_client_db(_client_db._filename);
}
////////////////////////////////////////////////////////////////////
@ -145,7 +145,7 @@ set_client_multifile_incomplete(string mfname) {
INLINE void DownloadDb::
set_client_multifile_complete(string mfname) {
(_client_db.get_multifile_record_named(mfname))->_status = Status_complete;
write_db(_client_db._filename, _client_db);
write_client_db(_client_db._filename);
}
////////////////////////////////////////////////////////////////////
@ -156,7 +156,7 @@ set_client_multifile_complete(string mfname) {
INLINE void DownloadDb::
set_client_multifile_decompressed(string mfname) {
(_client_db.get_multifile_record_named(mfname))->_status = Status_decompressed;
write_db(_client_db._filename, _client_db);
write_client_db(_client_db._filename);
}
////////////////////////////////////////////////////////////////////
@ -167,7 +167,7 @@ set_client_multifile_decompressed(string mfname) {
INLINE void DownloadDb::
set_client_multifile_extracted(string mfname) {
(_client_db.get_multifile_record_named(mfname))->_status = Status_extracted;
write_db(_client_db._filename, _client_db);
write_client_db(_client_db._filename);
}
@ -190,16 +190,6 @@ get_server_num_files(string mfname) const {
return (_server_db.get_multifile_record_named(mfname))->get_num_files();
}
////////////////////////////////////////////////////////////////////
// Function: DownloadDb::
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE string DownloadDb::
get_client_file_name(string mfname, int index) const {
return (_client_db.get_multifile_record_named(mfname))->get_file_name(index);
}
////////////////////////////////////////////////////////////////////
// Function: DownloadDb::
// Access: Public

View File

@ -22,9 +22,9 @@ PN_uint32 DownloadDb::_magic_number = 0xfeedfeed;
////////////////////////////////////////////////////////////////////
DownloadDb::
DownloadDb(Ramfile &server_file, Filename &client_file) {
_client_db = read_db(client_file);
_client_db = read_db(client_file, 0);
_client_db._filename = client_file;
_server_db = read_db(server_file);
_server_db = read_db(server_file, 1);
}
////////////////////////////////////////////////////////////////////
@ -77,7 +77,7 @@ output(ostream &out) const {
////////////////////////////////////////////////////////////////////
bool DownloadDb::
write_client_db(Filename &file) {
return write_db(file, _client_db);
return write_db(file, _client_db, 0);
}
@ -88,7 +88,7 @@ write_client_db(Filename &file) {
////////////////////////////////////////////////////////////////////
bool DownloadDb::
write_server_db(Filename &file) {
return write_db(file, _server_db);
return write_db(file, _server_db, 1);
}
////////////////////////////////////////////////////////////////////
@ -178,7 +178,7 @@ expand_client_multifile(string mfname) {
// Description:
////////////////////////////////////////////////////////////////////
DownloadDb::Db DownloadDb::
read_db(Filename &file) {
read_db(Filename &file, bool want_server_info) {
// Open the multifile for reading
ifstream read_stream;
file.set_binary();
@ -192,17 +192,19 @@ read_db(Filename &file) {
return db;
}
if (!db.read(read_stream)) {
if (!db.read(read_stream, want_server_info)) {
downloader_cat.error()
<< "DownloadDb::read() - Read failed: "
<< file << endl;
return db;
}
if (want_server_info) {
if (!read_version_map(read_stream)) {
downloader_cat.error()
<< "DownloadDb::read() - read_version_map() failed: "
<< file << endl;
}
}
return db;
}
@ -213,20 +215,22 @@ read_db(Filename &file) {
// Description:
////////////////////////////////////////////////////////////////////
DownloadDb::Db DownloadDb::
read_db(Ramfile &file) {
read_db(Ramfile &file, bool want_server_info) {
// Open the multifile for reading
istringstream read_stream(file._data);
Db db;
if (!db.read(read_stream)) {
if (!db.read(read_stream, want_server_info)) {
downloader_cat.error()
<< "DownloadDb::read() - Read failed" << endl;
return db;
}
if (want_server_info) {
if (!read_version_map(read_stream)) {
downloader_cat.error()
<< "DownloadDb::read() - read_version_map() failed" << endl;
}
}
return db;
}
@ -237,7 +241,7 @@ read_db(Ramfile &file) {
// Description:
////////////////////////////////////////////////////////////////////
bool DownloadDb::
write_db(Filename &file, Db db) {
write_db(Filename &file, Db db, bool want_server_info) {
ofstream write_stream;
file.set_binary();
if (!file.open_write(write_stream)) {
@ -250,8 +254,10 @@ write_db(Filename &file, Db db) {
downloader_cat.debug()
<< "Writing to file: " << file << endl;
db.write(write_stream);
db.write(write_stream, want_server_info);
if (want_server_info) {
write_version_map(write_stream);
}
write_stream.close();
return true;
}
@ -652,7 +658,7 @@ parse_fr(uchar *start, int size) {
// Description:
////////////////////////////////////////////////////////////////////
bool DownloadDb::Db::
read(istream &read_stream) {
read(istream &read_stream, bool want_server_info) {
// Make a little buffer to read the header into
uchar *header_buf = new uchar[_header_length];
@ -697,6 +703,9 @@ read(istream &read_stream) {
PT(DownloadDb::MultifileRecord) mfr = parse_mfr(header_buf, mfr_length);
delete header_buf;
// Only read in the individual file info if you are the server
if (want_server_info) {
// Read off all the file records this multifile has
for (int j = 0; j<mfr->_num_files; j++) {
// The file record header is just one int which
@ -726,6 +735,7 @@ read(istream &read_stream) {
// Add this file record to the current multifilerecord
mfr->add_file_record(fr);
}
}
// Add the current multifilerecord to our database
add_multifile_record(mfr);
@ -743,7 +753,7 @@ read(istream &read_stream) {
// Description:
////////////////////////////////////////////////////////////////////
bool DownloadDb::Db::
write(ofstream &write_stream) {
write(ofstream &write_stream, bool want_server_info) {
write_header(write_stream);
// Declare these outside the loop so we do not keep creating
@ -793,6 +803,8 @@ write(ofstream &write_stream) {
string msg = _datagram.get_message();
write_stream.write(msg.data(), msg.length());
// Only write out the file information if you are the server
if (want_server_info) {
// Now iterate over this multifile's files writing them to the stream
// Iterate over the multifiles writing them to the stream
vector< PT(FileRecord) >::const_iterator j = (*i)->_file_records.begin();
@ -820,7 +832,7 @@ write(ofstream &write_stream) {
string msg = _datagram.get_message();
write_stream.write(msg.data(), msg.length());
}
}
}
return true;

View File

@ -92,7 +92,8 @@ PUBLISHED:
INLINE int get_client_num_files(string mfname) const;
INLINE int get_server_num_files(string mfname) const;
INLINE string get_client_file_name(string mfname, int index) const;
// The client does not store the names of all the files anymore
// INLINE string get_client_file_name(string mfname, int index) const;
INLINE string get_server_file_name(string mfname, int index) const;
// Queries from the Launcher
@ -156,8 +157,8 @@ public:
int parse_record_header(uchar *start, int size);
PT(MultifileRecord) parse_mfr(uchar *start, int size);
PT(FileRecord) parse_fr(uchar *start, int size);
bool read(istream &read_stream);
bool write(ofstream &write_stream);
bool read(istream &read_stream, bool want_server_info);
bool write(ofstream &write_stream, bool want_server_info);
Filename _filename;
MultifileRecords _mfile_records;
private:
@ -170,12 +171,12 @@ public:
};
PUBLISHED:
Db read_db(Filename &file);
Db read_db(Ramfile &file);
bool write_db(Filename &file, Db db);
Db read_db(Filename &file, bool want_server_info);
Db read_db(Ramfile &file, bool want_server_info);
bool write_db(Filename &file, Db db, bool want_server_info);
public:
// The doenload db stores two databases, one that represents the client's state
// The download db stores two databases, one that represents the client's state
// and one that represents the server state
Db _client_db;
Db _server_db;