mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 08:44:19 -04:00
*** empty log message ***
This commit is contained in:
parent
89285f006b
commit
8cdfbeedcf
@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
#include "executionEnvironment.h"
|
#include "executionEnvironment.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdio.h> // for perror
|
||||||
|
|
||||||
#ifdef WIN32_VC
|
#ifdef WIN32_VC
|
||||||
// Windows requires this for getcwd().
|
// Windows requires this for getcwd().
|
||||||
@ -12,7 +14,6 @@
|
|||||||
#define getcwd _getcwd
|
#define getcwd _getcwd
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
// We define the symbol PREREAD_ENVIRONMENT if we cannot rely on
|
// We define the symbol PREREAD_ENVIRONMENT if we cannot rely on
|
||||||
// getenv() to read environment variables at static init time. In
|
// getenv() to read environment variables at static init time. In
|
||||||
@ -57,7 +58,7 @@ ExecutionEnvironment() {
|
|||||||
// Access: Public, Static
|
// Access: Public, Static
|
||||||
// Description: Returns the name of the current working directory.
|
// Description: Returns the name of the current working directory.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
string ExecutionEnvironment::
|
Filename ExecutionEnvironment::
|
||||||
get_cwd() {
|
get_cwd() {
|
||||||
// getcwd() requires us to allocate a dynamic buffer and grow it on
|
// getcwd() requires us to allocate a dynamic buffer and grow it on
|
||||||
// demand.
|
// demand.
|
||||||
@ -79,7 +80,7 @@ get_cwd() {
|
|||||||
assert(buffer != (char *)NULL);
|
assert(buffer != (char *)NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
return string(buffer);
|
return Filename::from_os_specific(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include <dtoolbase.h>
|
#include <dtoolbase.h>
|
||||||
|
|
||||||
#include "vector_string.h"
|
#include "vector_string.h"
|
||||||
|
#include "filename.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
@ -33,7 +34,7 @@ public:
|
|||||||
|
|
||||||
INLINE static string get_binary_name();
|
INLINE static string get_binary_name();
|
||||||
|
|
||||||
static string get_cwd();
|
static Filename get_cwd();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool ns_has_environment_variable(const string &var) const;
|
bool ns_has_environment_variable(const string &var) const;
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#include "filename.h"
|
#include "filename.h"
|
||||||
#include "dSearchPath.h"
|
#include "dSearchPath.h"
|
||||||
|
#include "executionEnvironment.h"
|
||||||
|
|
||||||
#include <stdio.h> // For rename()
|
#include <stdio.h> // For rename()
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@ -191,10 +192,13 @@ Filename::
|
|||||||
Filename(const Filename &dirname, const Filename &basename) {
|
Filename(const Filename &dirname, const Filename &basename) {
|
||||||
if (dirname.empty()) {
|
if (dirname.empty()) {
|
||||||
(*this) = basename;
|
(*this) = basename;
|
||||||
} else if (basename.empty()) {
|
|
||||||
(*this) = dirname;
|
|
||||||
} else {
|
} else {
|
||||||
(*this) = dirname.get_fullpath() + "/" + basename.get_fullpath();
|
string dirpath = dirname.get_fullpath();
|
||||||
|
if (dirpath[dirpath.length() - 1] == '/') {
|
||||||
|
(*this) = dirpath + basename.get_fullpath();
|
||||||
|
} else {
|
||||||
|
(*this) = dirpath + "/" + basename.get_fullpath();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_flags = 0;
|
_flags = 0;
|
||||||
}
|
}
|
||||||
@ -474,6 +478,45 @@ standardize() {
|
|||||||
(*this) = result;
|
(*this) = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: Filename::make_absolute
|
||||||
|
// Access: Public
|
||||||
|
// Description: Converts the filename to a fully-qualified pathname
|
||||||
|
// from the root (if it is a relative pathname), and
|
||||||
|
// then standardizes it (see standardize()).
|
||||||
|
//
|
||||||
|
// This is sometimes a little problematic, since it may
|
||||||
|
// convert the file to its 'true' absolute pathname,
|
||||||
|
// which could be an ugly NFS-named file, irrespective
|
||||||
|
// of symbolic links
|
||||||
|
// (e.g. /.automount/dimbo/root/usr2/fit/people/drose
|
||||||
|
// instead of /fit/people/drose); besides being ugly,
|
||||||
|
// filenames like this may not be consistent across
|
||||||
|
// multiple different platforms.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void Filename::
|
||||||
|
make_absolute() {
|
||||||
|
make_absolute(ExecutionEnvironment::get_cwd());
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: Filename::make_absolute
|
||||||
|
// Access: Public
|
||||||
|
// Description: Converts the filename to a fully-qualified filename
|
||||||
|
// from the root (if it is a relative filename), and
|
||||||
|
// then standardizes it (see standardize()). This
|
||||||
|
// flavor accepts a specific starting directory that the
|
||||||
|
// filename is known to be relative to.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void Filename::
|
||||||
|
make_absolute(const Filename &start_directory) {
|
||||||
|
if (is_local()) {
|
||||||
|
(*this) = Filename(start_directory, _filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
standardize();
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: Filename::to_os_specific
|
// Function: Filename::to_os_specific
|
||||||
// Access: Public
|
// Access: Public
|
||||||
@ -485,6 +528,8 @@ standardize() {
|
|||||||
// instance). Returns the string representing the
|
// instance). Returns the string representing the
|
||||||
// converted filename, but does not change the Filename
|
// converted filename, but does not change the Filename
|
||||||
// itself.
|
// itself.
|
||||||
|
//
|
||||||
|
// See also from_os_specific().
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
string Filename::
|
string Filename::
|
||||||
to_os_specific() const {
|
to_os_specific() const {
|
||||||
|
@ -116,6 +116,8 @@ public:
|
|||||||
// The following functions deal with the outside world.
|
// The following functions deal with the outside world.
|
||||||
|
|
||||||
INLINE bool is_local() const;
|
INLINE bool is_local() const;
|
||||||
|
void make_absolute();
|
||||||
|
void make_absolute(const Filename &start_directory);
|
||||||
|
|
||||||
string to_os_specific() const;
|
string to_os_specific() const;
|
||||||
|
|
||||||
|
@ -900,7 +900,7 @@ int framework_main(int argc, char *argv[]) {
|
|||||||
for (int a = 1; a < argc; a++)
|
for (int a = 1; a < argc; a++)
|
||||||
if ((argv[a] != (char*)0L) && ((argv[a])[0] != '-') &&
|
if ((argv[a] != (char*)0L) && ((argv[a])[0] != '-') &&
|
||||||
((argv[a])[0] != '+') && ((argv[a])[0] != '#'))
|
((argv[a])[0] != '+') && ((argv[a])[0] != '#'))
|
||||||
files.push_back(argv[a]);
|
files.push_back(Filename::from_os_specific(argv[a]));
|
||||||
|
|
||||||
// load display modules
|
// load display modules
|
||||||
GraphicsPipe::resolve_modules();
|
GraphicsPipe::resolve_modules();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user