mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
better fix for the path reset
This commit is contained in:
parent
5b42b04264
commit
6eaa77ac70
@ -63,19 +63,19 @@ MayaApi(const string &program_name) {
|
|||||||
|
|
||||||
// Furthermore, the current directory may change during the call to
|
// Furthermore, the current directory may change during the call to
|
||||||
// any Maya function! Egad!
|
// any Maya function! Egad!
|
||||||
Filename cwd = ExecutionEnvironment::get_cwd();
|
_cwd = ExecutionEnvironment::get_cwd();
|
||||||
MStatus stat = MLibrary::initialize((char *)program_name.c_str());
|
MStatus stat = MLibrary::initialize((char *)program_name.c_str());
|
||||||
|
|
||||||
// Restore the current directory.
|
// Restore the current directory.
|
||||||
string dirname = cwd.to_os_specific();
|
string dirname = _cwd.to_os_specific();
|
||||||
if (chdir(dirname.c_str()) < 0) {
|
if (chdir(dirname.c_str()) < 0) {
|
||||||
maya_cat.warning()
|
maya_cat.warning()
|
||||||
<< "Unable to restore current directory to " << cwd
|
<< "Unable to restore current directory to " << _cwd
|
||||||
<< " after initializing Maya.\n";
|
<< " after initializing Maya.\n";
|
||||||
} else {
|
} else {
|
||||||
if (maya_cat.is_debug()) {
|
if (maya_cat.is_debug()) {
|
||||||
maya_cat.debug()
|
maya_cat.debug()
|
||||||
<< "Restored current directory to " << cwd << "\n";
|
<< "Restored current directory to " << _cwd << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,8 +258,7 @@ read(const Filename &filename) {
|
|||||||
// even on Windows.
|
// even on Windows.
|
||||||
string os_filename = filename.to_os_generic();
|
string os_filename = filename.to_os_generic();
|
||||||
|
|
||||||
Filename cwd = ExecutionEnvironment::get_cwd();
|
string dirname = _cwd.to_os_specific();
|
||||||
string dirname = cwd.to_os_specific();
|
|
||||||
if (maya_cat.is_debug()) {
|
if (maya_cat.is_debug()) {
|
||||||
maya_cat.debug() << "cwd(read:before): " << dirname.c_str() << endl;
|
maya_cat.debug() << "cwd(read:before): " << dirname.c_str() << endl;
|
||||||
}
|
}
|
||||||
@ -273,12 +272,12 @@ read(const Filename &filename) {
|
|||||||
// any Maya function! Egad!
|
// any Maya function! Egad!
|
||||||
if (chdir(dirname.c_str()) < 0) {
|
if (chdir(dirname.c_str()) < 0) {
|
||||||
maya_cat.warning()
|
maya_cat.warning()
|
||||||
<< "Unable to restore current directory after ::read to " << cwd
|
<< "Unable to restore current directory after ::read to " << _cwd
|
||||||
<< " after initializing Maya.\n";
|
<< " after initializing Maya.\n";
|
||||||
} else {
|
} else {
|
||||||
if (maya_cat.is_debug()) {
|
if (maya_cat.is_debug()) {
|
||||||
maya_cat.debug()
|
maya_cat.debug()
|
||||||
<< "Restored current directory after ::read to " << cwd << "\n";
|
<< "Restored current directory after ::read to " << _cwd << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!stat) {
|
if (!stat) {
|
||||||
@ -299,8 +298,7 @@ write(const Filename &filename) {
|
|||||||
maya_cat.info() << "Writing " << filename << "\n";
|
maya_cat.info() << "Writing " << filename << "\n";
|
||||||
string os_filename = filename.to_os_generic();
|
string os_filename = filename.to_os_generic();
|
||||||
|
|
||||||
Filename cwd = ExecutionEnvironment::get_cwd();
|
string dirname = _cwd.to_os_specific();
|
||||||
string dirname = cwd.to_os_specific();
|
|
||||||
if (maya_cat.is_debug()) {
|
if (maya_cat.is_debug()) {
|
||||||
maya_cat.debug() << "cwd(write:before): " << dirname.c_str() << endl;
|
maya_cat.debug() << "cwd(write:before): " << dirname.c_str() << endl;
|
||||||
}
|
}
|
||||||
@ -316,7 +314,6 @@ write(const Filename &filename) {
|
|||||||
stat.perror(os_filename.c_str());
|
stat.perror(os_filename.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Beginning with Maya2008, the call to read seem to change
|
// Beginning with Maya2008, the call to read seem to change
|
||||||
// the current directory specially if there is a refrence file! Yikes!
|
// the current directory specially if there is a refrence file! Yikes!
|
||||||
|
|
||||||
@ -324,15 +321,14 @@ write(const Filename &filename) {
|
|||||||
// any Maya function! Egad!
|
// any Maya function! Egad!
|
||||||
if (chdir(dirname.c_str()) < 0) {
|
if (chdir(dirname.c_str()) < 0) {
|
||||||
maya_cat.warning()
|
maya_cat.warning()
|
||||||
<< "Unable to restore current directory after ::write to " << cwd
|
<< "Unable to restore current directory after ::write to " << _cwd
|
||||||
<< " after initializing Maya.\n";
|
<< " after initializing Maya.\n";
|
||||||
} else {
|
} else {
|
||||||
if (maya_cat.is_debug()) {
|
if (maya_cat.is_debug()) {
|
||||||
maya_cat.debug()
|
maya_cat.debug()
|
||||||
<< "Restored current directory after ::write to " << cwd << "\n";
|
<< "Restored current directory after ::write to " << _cwd << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,6 +52,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
bool _is_valid;
|
bool _is_valid;
|
||||||
bool _plug_in;
|
bool _plug_in;
|
||||||
|
Filename _cwd;
|
||||||
static MayaApi *_global_api;
|
static MayaApi *_global_api;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user