Merge branch 'master' into cmake

This commit is contained in:
Sam Edwards 2015-11-15 22:54:32 -08:00
commit b907a0c53e
8 changed files with 46 additions and 21 deletions

View File

@ -19,7 +19,7 @@
// Description:
////////////////////////////////////////////////////////////////////
INLINE VirtualFileMountRamdisk::FileBase::
FileBase(const string &basename) : _basename(basename), _timestamp(0) {
FileBase(const string &basename) : _basename(basename), _timestamp(time(NULL)) {
}
////////////////////////////////////////////////////////////////////

View File

@ -38,9 +38,9 @@ VirtualFileMountRamdisk() : _root("") {
////////////////////////////////////////////////////////////////////
bool VirtualFileMountRamdisk::
has_file(const Filename &file) const {
((VirtualFileMountRamdisk *)this)->_lock.acquire();
_lock.acquire();
PT(FileBase) f = _root.do_find_file(file);
((VirtualFileMountRamdisk *)this)->_lock.release();
_lock.release();
return (f != NULL);
}
@ -197,9 +197,9 @@ make_directory(const Filename &file) {
////////////////////////////////////////////////////////////////////
bool VirtualFileMountRamdisk::
is_directory(const Filename &file) const {
((VirtualFileMountRamdisk *)this)->_lock.acquire();
_lock.acquire();
PT(FileBase) f = _root.do_find_file(file);
((VirtualFileMountRamdisk *)this)->_lock.release();
_lock.release();
return (f != NULL && f->is_directory());
}
@ -211,9 +211,9 @@ is_directory(const Filename &file) const {
////////////////////////////////////////////////////////////////////
bool VirtualFileMountRamdisk::
is_regular_file(const Filename &file) const {
((VirtualFileMountRamdisk *)this)->_lock.acquire();
_lock.acquire();
PT(FileBase) f = _root.do_find_file(file);
((VirtualFileMountRamdisk *)this)->_lock.release();
_lock.release();
return (f != NULL && !f->is_directory());
}
@ -238,9 +238,9 @@ is_writable(const Filename &file) const {
////////////////////////////////////////////////////////////////////
istream *VirtualFileMountRamdisk::
open_read_file(const Filename &file) const {
((VirtualFileMountRamdisk *)this)->_lock.acquire();
_lock.acquire();
PT(FileBase) f = _root.do_find_file(file);
((VirtualFileMountRamdisk *)this)->_lock.release();
_lock.release();
if (f == (FileBase *)NULL || f->is_directory()) {
return NULL;
}
@ -269,6 +269,7 @@ open_write_file(const Filename &file, bool truncate) {
if (truncate) {
// Reset to an empty string.
f->_data.str(string());
f->_timestamp = time(NULL);
}
return new OSubStream(&f->_wrapper, 0, 0);
@ -311,6 +312,12 @@ open_read_write_file(const Filename &file, bool truncate) {
return NULL;
}
if (truncate) {
// Reset to an empty string.
f->_data.str(string());
f->_timestamp = time(NULL);
}
return new SubStream(&f->_wrapper, 0, 0);
}
@ -346,9 +353,9 @@ open_read_append_file(const Filename &file) {
////////////////////////////////////////////////////////////////////
streamsize VirtualFileMountRamdisk::
get_file_size(const Filename &file, istream *stream) const {
((VirtualFileMountRamdisk *)this)->_lock.acquire();
_lock.acquire();
PT(FileBase) f = _root.do_find_file(file);
((VirtualFileMountRamdisk *)this)->_lock.release();
_lock.release();
if (f == (FileBase *)NULL || f->is_directory()) {
return 0;
}
@ -365,9 +372,9 @@ get_file_size(const Filename &file, istream *stream) const {
////////////////////////////////////////////////////////////////////
streamsize VirtualFileMountRamdisk::
get_file_size(const Filename &file) const {
((VirtualFileMountRamdisk *)this)->_lock.acquire();
_lock.acquire();
PT(FileBase) f = _root.do_find_file(file);
((VirtualFileMountRamdisk *)this)->_lock.release();
_lock.release();
if (f == (FileBase *)NULL || f->is_directory()) {
return 0;
}
@ -392,7 +399,15 @@ get_file_size(const Filename &file) const {
////////////////////////////////////////////////////////////////////
time_t VirtualFileMountRamdisk::
get_timestamp(const Filename &file) const {
return 0;
_lock.acquire();
PT(FileBase) f = _root.do_find_file(file);
if (f.is_null()) {
_lock.release();
return 0;
}
time_t timestamp = f->_timestamp;
_lock.release();
return timestamp;
}
////////////////////////////////////////////////////////////////////
@ -405,17 +420,17 @@ get_timestamp(const Filename &file) const {
////////////////////////////////////////////////////////////////////
bool VirtualFileMountRamdisk::
scan_directory(vector_string &contents, const Filename &dir) const {
((VirtualFileMountRamdisk *)this)->_lock.acquire();
_lock.acquire();
PT(FileBase) f = _root.do_find_file(dir);
if (f == (FileBase *)NULL || !f->is_directory()) {
((VirtualFileMountRamdisk *)this)->_lock.release();
_lock.release();
return false;
}
Directory *f2 = DCAST(Directory, f);
bool result = f2->do_scan_directory(contents);
((VirtualFileMountRamdisk *)this)->_lock.release();
_lock.release();
return result;
}
@ -440,6 +455,7 @@ atomic_compare_and_exchange_contents(const Filename &file, string &orig_contents
orig_contents = f2->_data.str();
if (orig_contents == old_contents) {
f2->_data.str(new_contents);
f2->_timestamp = time(NULL);
retval = true;
}
@ -454,17 +470,17 @@ atomic_compare_and_exchange_contents(const Filename &file, string &orig_contents
////////////////////////////////////////////////////////////////////
bool VirtualFileMountRamdisk::
atomic_read_contents(const Filename &file, string &contents) const {
((VirtualFileMountRamdisk *)this)->_lock.acquire();
_lock.acquire();
PT(FileBase) f = _root.do_find_file(file);
if (f == (FileBase *)NULL || f->is_directory()) {
((VirtualFileMountRamdisk *)this)->_lock.release();
_lock.release();
return false;
}
File *f2 = DCAST(File, f);
contents = f2->_data.str();
((VirtualFileMountRamdisk *)this)->_lock.release();
_lock.release();
return true;
}
@ -575,6 +591,7 @@ do_create_file(const string &filename) {
}
PT(File) file = new File(filename);
_files.insert(file.p());
_timestamp = time(NULL);
return file;
}
@ -625,6 +642,7 @@ do_make_directory(const string &filename) {
}
PT(Directory) file = new Directory(filename);
_files.insert(file.p());
_timestamp = time(NULL);
return file;
}
@ -669,6 +687,7 @@ do_delete_file(const string &filename) {
}
}
_files.erase(fi);
_timestamp = time(NULL);
return file;
}
return NULL;

View File

@ -158,7 +158,7 @@ private:
};
Directory _root;
MutexImpl _lock;
mutable MutexImpl _lock;
public:
virtual TypeHandle get_type() const {

View File

@ -13,6 +13,7 @@
////////////////////////////////////////////////////////////////////
#include "virtualFileMountSystem.h"
#include "virtualFileSystem.h"
TypeHandle VirtualFileMountSystem::_type_handle;

View File

@ -16,6 +16,7 @@
#include "wglGraphicsPipe.h"
#include "config_wgldisplay.h"
#include "glgsg.h"
#include "wglGraphicsStateGuardian.h"
#include "pStatTimer.h"
#include <wingdi.h>

View File

@ -17,6 +17,7 @@
#include "config_windisplay.h"
#include "wglGraphicsWindow.h"
#include "wglGraphicsBuffer.h"
#include "wglGraphicsStateGuardian.h"
typedef enum {Software, MCD, ICD} OGLDriverType;

View File

@ -13,7 +13,9 @@
////////////////////////////////////////////////////////////////////
#include "wglGraphicsStateGuardian.h"
#include "config_wgldisplay.h"
#include "wglGraphicsBuffer.h"
#include "wglGraphicsPipe.h"
#include "string_utils.h"
TypeHandle wglGraphicsStateGuardian::_type_handle;

View File

@ -18,6 +18,7 @@
#include "wglGraphicsPipe.h"
#include "pStatTimer.h"
#include "glgsg.h"
#include "wglGraphicsStateGuardian.h"
#include <wingdi.h>