*** empty log message ***
This commit is contained in:
parent
b7e64160c9
commit
7bd3f3f9e7
|
|
@ -638,20 +638,22 @@ to_os_specific() const {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
bool Filename::
|
||||
exists() const {
|
||||
string os_specific = to_os_specific();
|
||||
|
||||
#ifdef WIN32_VC
|
||||
// Windows puts underscores in front of most of the function and
|
||||
// structure names it borrowed from Unix. Embrace and extend.
|
||||
struct _stat this_buf;
|
||||
bool exists = false;
|
||||
|
||||
if (_stat(to_os_specific().c_str(), &this_buf) == 0) {
|
||||
if (_stat(os_specific.c_str(), &this_buf) == 0) {
|
||||
exists = true;
|
||||
}
|
||||
#else // WIN32_VC
|
||||
struct stat this_buf;
|
||||
bool exists = false;
|
||||
|
||||
if (stat(to_os_specific().c_str(), &this_buf) == 0) {
|
||||
if (stat(os_specific.c_str(), &this_buf) == 0) {
|
||||
exists = true;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -668,18 +670,20 @@ exists() const {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
bool Filename::
|
||||
is_regular_file() const {
|
||||
string os_specific = to_os_specific();
|
||||
|
||||
#ifdef WIN32_VC
|
||||
struct _stat this_buf;
|
||||
bool isreg = false;
|
||||
|
||||
if (_stat(to_os_specific().c_str(), &this_buf) == 0) {
|
||||
if (_stat(os_specific.c_str(), &this_buf) == 0) {
|
||||
isreg = (this_buf.st_mode & _S_IFREG) != 0;
|
||||
}
|
||||
#else // WIN32_VC
|
||||
struct stat this_buf;
|
||||
bool isreg = false;
|
||||
|
||||
if (stat(to_os_specific().c_str(), &this_buf) == 0) {
|
||||
if (stat(os_specific.c_str(), &this_buf) == 0) {
|
||||
isreg = S_ISREG(this_buf.st_mode);
|
||||
}
|
||||
#endif
|
||||
|
|
@ -695,18 +699,20 @@ is_regular_file() const {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
bool Filename::
|
||||
is_directory() const {
|
||||
string os_specific = to_os_specific();
|
||||
|
||||
#ifdef WIN32_VC
|
||||
struct _stat this_buf;
|
||||
bool isdir = false;
|
||||
|
||||
if (_stat(to_os_specific().c_str(), &this_buf) == 0) {
|
||||
if (_stat(os_specific.c_str(), &this_buf) == 0) {
|
||||
isdir = (this_buf.st_mode & _S_IFDIR) != 0;
|
||||
}
|
||||
#else // WIN32_VC
|
||||
struct stat this_buf;
|
||||
bool isdir = false;
|
||||
|
||||
if (stat(to_os_specific().c_str(), &this_buf) == 0) {
|
||||
if (stat(os_specific.c_str(), &this_buf) == 0) {
|
||||
isdir = S_ISDIR(this_buf.st_mode);
|
||||
}
|
||||
#endif
|
||||
|
|
@ -722,19 +728,21 @@ is_directory() const {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
bool Filename::
|
||||
is_executable() const {
|
||||
if (exists()) {
|
||||
#ifdef WIN32_VC
|
||||
// no access() in windows, but to our advantage executables can only
|
||||
// end in .exe or .com
|
||||
string stmp = to_os_specific();
|
||||
stmp = stmp.substr(stmp.rfind(".") + 1);
|
||||
if ((stmp == "exe") || (stmp == "com"))
|
||||
return true;
|
||||
#else /* WIN32_VC */
|
||||
if (access(to_os_specific().c_str(), X_OK) == 0)
|
||||
return true;
|
||||
#endif /* WIN32_VC */
|
||||
// no access() in windows, but to our advantage executables can only
|
||||
// end in .exe or .com
|
||||
string extension = get_extension();
|
||||
if (extension == "exe" || extension == "com") {
|
||||
return exists();
|
||||
}
|
||||
|
||||
#else /* WIN32_VC */
|
||||
string os_specific = to_os_specific();
|
||||
if (access(os_specific.c_str(), X_OK) == 0) {
|
||||
return true;
|
||||
}
|
||||
#endif /* WIN32_VC */
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -756,33 +764,35 @@ int Filename::
|
|||
compare_timestamps(const Filename &other,
|
||||
bool this_missing_is_old,
|
||||
bool other_missing_is_old) const {
|
||||
string os_specific = to_os_specific();
|
||||
string other_os_specific = other.to_os_specific();
|
||||
|
||||
#ifdef WIN32_VC
|
||||
struct _stat this_buf;
|
||||
bool this_exists = false;
|
||||
|
||||
if (_stat(to_os_specific().c_str(), &this_buf) == 0) {
|
||||
if (_stat(os_specific.c_str(), &this_buf) == 0) {
|
||||
this_exists = true;
|
||||
}
|
||||
|
||||
struct _stat other_buf;
|
||||
bool other_exists = false;
|
||||
|
||||
if (_stat(other.to_os_specific().c_str(), &other_buf) == 0) {
|
||||
if (_stat(other_os_specific.c_str(), &other_buf) == 0) {
|
||||
other_exists = true;
|
||||
}
|
||||
#else // WIN32_VC
|
||||
struct stat this_buf;
|
||||
bool this_exists = false;
|
||||
|
||||
if (stat(to_os_specific().c_str(), &this_buf) == 0) {
|
||||
if (stat(os_specific.c_str(), &this_buf) == 0) {
|
||||
this_exists = true;
|
||||
}
|
||||
|
||||
struct stat other_buf;
|
||||
bool other_exists = false;
|
||||
|
||||
if (stat(other.to_os_specific().c_str(), &other_buf) == 0) {
|
||||
if (stat(other_os_specific.c_str(), &other_buf) == 0) {
|
||||
other_exists = true;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -1037,8 +1047,9 @@ open_read(ifstream &stream) const {
|
|||
}
|
||||
#endif
|
||||
|
||||
string os_specific = to_os_specific();
|
||||
stream.clear();
|
||||
stream.open(to_os_specific().c_str(), open_mode);
|
||||
stream.open(os_specific.c_str(), open_mode);
|
||||
return (!stream.fail());
|
||||
}
|
||||
|
||||
|
|
@ -1068,10 +1079,11 @@ open_write(ofstream &stream) const {
|
|||
#endif
|
||||
|
||||
stream.clear();
|
||||
string os_specific = to_os_specific();
|
||||
#ifdef WIN32_VC
|
||||
stream.open(to_os_specific().c_str(), open_mode);
|
||||
stream.open(os_specific.c_str(), open_mode);
|
||||
#else
|
||||
stream.open(to_os_specific().c_str(), open_mode, 0666);
|
||||
stream.open(os_specific.c_str(), open_mode, 0666);
|
||||
#endif
|
||||
|
||||
return (!stream.fail());
|
||||
|
|
@ -1103,10 +1115,11 @@ open_append(ofstream &stream) const {
|
|||
#endif
|
||||
|
||||
stream.clear();
|
||||
string os_specific = to_os_specific();
|
||||
#ifdef WIN32_VC
|
||||
stream.open(to_os_specific().c_str(), open_mode);
|
||||
stream.open(os_specific.c_str(), open_mode);
|
||||
#else
|
||||
stream.open(to_os_specific().c_str(), open_mode, 0666);
|
||||
stream.open(os_specific.c_str(), open_mode, 0666);
|
||||
#endif
|
||||
|
||||
return (!stream.fail());
|
||||
|
|
@ -1138,10 +1151,11 @@ open_read_write(fstream &stream) const {
|
|||
#endif
|
||||
|
||||
stream.clear();
|
||||
string os_specific = to_os_specific();
|
||||
#ifdef WIN32_VC
|
||||
stream.open(to_os_specific().c_str(), open_mode);
|
||||
stream.open(os_specific.c_str(), open_mode);
|
||||
#else
|
||||
stream.open(to_os_specific().c_str(), open_mode, 0666);
|
||||
stream.open(os_specific.c_str(), open_mode, 0666);
|
||||
#endif
|
||||
|
||||
return (!stream.fail());
|
||||
|
|
@ -1159,20 +1173,20 @@ bool Filename::
|
|||
touch() const {
|
||||
#ifdef HAVE_UTIME_H
|
||||
// Most Unix systems can do this explicitly.
|
||||
string filename = to_os_specific();
|
||||
int result = utime(filename.c_str(), NULL);
|
||||
string os_specific = to_os_specific();
|
||||
int result = utime(os_specific.c_str(), NULL);
|
||||
if (result < 0) {
|
||||
if (errno == ENOENT) {
|
||||
// So the file doesn't already exist; create it.
|
||||
int fd = creat(filename.c_str(), 0666);
|
||||
int fd = creat(os_specific.c_str(), 0666);
|
||||
if (fd < 0) {
|
||||
perror(filename.c_str());
|
||||
perror(os_specific.c_str());
|
||||
return false;
|
||||
}
|
||||
close(fd);
|
||||
return true;
|
||||
}
|
||||
perror(filename.c_str());
|
||||
perror(os_specific.c_str());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
@ -1196,7 +1210,8 @@ touch() const {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
bool Filename::
|
||||
unlink() const {
|
||||
return (::unlink(to_os_specific().c_str()) == 0);
|
||||
string os_specific = to_os_specific();
|
||||
return (::unlink(os_specific.c_str()) == 0);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1210,8 +1225,10 @@ unlink() const {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
bool Filename::
|
||||
rename_to(const Filename &other) const {
|
||||
return (rename(to_os_specific().c_str(),
|
||||
other.to_os_specific().c_str()) == 0);
|
||||
string os_specific = to_os_specific();
|
||||
string other_os_specific = other.to_os_specific();
|
||||
return (rename(os_specific.c_str(),
|
||||
other_os_specific.c_str()) == 0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -36,7 +36,8 @@ load_dso_error()
|
|||
|
||||
void *
|
||||
load_dso(const Filename &filename) {
|
||||
return LoadLibrary(filename.to_os_specific().c_str());
|
||||
string os_specific = filename.to_os_specific();
|
||||
return LoadLibrary(os_specific.c_str());
|
||||
}
|
||||
|
||||
string
|
||||
|
|
@ -71,7 +72,8 @@ load_dso(const Filename &filename) {
|
|||
enum DYLD_BOOL result;
|
||||
cerr << "_dyld_present() = " << _dyld_present() << endl;
|
||||
cerr << "_dyld_image_count() = " << _dyld_image_count() << endl;
|
||||
result = NSAddLibrary(filename.to_os_specific().c_str());
|
||||
string os_specific = filename.to_os_specific();
|
||||
result = NSAddLibrary(os_specific().c_str());
|
||||
if (result == FALSE) {
|
||||
cerr << "Failed to load '" << filename << "'" << endl;
|
||||
}
|
||||
|
|
@ -117,7 +119,8 @@ load_dso_error() {
|
|||
|
||||
void *
|
||||
load_dso(const Filename &filename) {
|
||||
return dlopen(filename.to_os_specific().c_str(), RTLD_NOW);
|
||||
string os_specific = filename.to_os_specific();
|
||||
return dlopen(os_specific.c_str(), RTLD_NOW);
|
||||
}
|
||||
|
||||
string
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ void audio_load_loaders(void) {
|
|||
Filename dlname = Filename::dso_filename("libaudio_load_" + (*i).Val() +
|
||||
".so");
|
||||
audio_cat->info() << "loading '" << (*i).Val() << "' loader" << endl;
|
||||
void* tmp = load_dso(dlname.to_os_specific());
|
||||
void* tmp = load_dso(dlname);
|
||||
if (tmp == (void*)0L)
|
||||
audio_cat->info() << "unable to load: " << load_dso_error() << endl;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -334,7 +334,7 @@ void GraphicsPipe::resolve_modules(void) {
|
|||
Filename dlname = Filename::dso_filename("lib" + (*i).Val() + ".so");
|
||||
display_cat.info()
|
||||
<< "loading display module: " << dlname.to_os_specific() << endl;
|
||||
void *tmp = load_dso(dlname.to_os_specific());
|
||||
void *tmp = load_dso(dlname);
|
||||
if (tmp == (void*)0L) {
|
||||
display_cat.info()
|
||||
<< "Unable to load: " << load_dso_error() << endl;
|
||||
|
|
@ -344,7 +344,7 @@ void GraphicsPipe::resolve_modules(void) {
|
|||
Filename dlname = Filename::dso_filename("lib" + (*i).Val() + ".so");
|
||||
display_cat.info()
|
||||
<< "loading GSG module: " << dlname.to_os_specific() << endl;
|
||||
void *tmp = load_dso(dlname.to_os_specific());
|
||||
void *tmp = load_dso(dlname);
|
||||
if (tmp == (void*)0L) {
|
||||
display_cat.info()
|
||||
<< "Unable to load: " << load_dso_error() << endl;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ int main(int argc, char** argv)
|
|||
Filename filename = argv[i];
|
||||
if (filename.get_extension() == ".so") {
|
||||
filename.set_type(Filename::T_dso);
|
||||
load_dso(filename.to_os_specific());
|
||||
load_dso(filename);
|
||||
}
|
||||
}
|
||||
if (task_list == (service_list*)0L) {
|
||||
|
|
@ -59,7 +59,7 @@ int main(int argc, char** argv)
|
|||
{
|
||||
Filename filename = message_to_main_thread->get_lib();
|
||||
filename.set_type(Filename::F_dso);
|
||||
load_dso(filename.to_os_specific());
|
||||
load_dso(filename);
|
||||
}
|
||||
case main_thread_message::RESCAN:
|
||||
for (j=task_list->begin(); j!=task_list->end(); ++j)
|
||||
|
|
|
|||
|
|
@ -229,7 +229,7 @@ load_file_types() {
|
|||
Filename dlname = Filename::dso_filename("lib" + (*ti).Val() + ".so");
|
||||
loader_cat.info()
|
||||
<< "loading file type module: " << dlname.to_os_specific() << endl;
|
||||
void *tmp = load_dso(dlname.to_os_specific());
|
||||
void *tmp = load_dso(dlname);
|
||||
if (tmp == (void *)NULL) {
|
||||
loader_cat.info()
|
||||
<< "Unable to load: " << load_dso_error() << endl;
|
||||
|
|
|
|||
Loading…
Reference in New Issue