Fixed a relative path usage

This commit is contained in:
Stas Degteff 2005-11-06 11:50:08 +00:00
parent 8b49add1be
commit d0ca6c8af9
3 changed files with 13 additions and 11 deletions

View File

@ -10,13 +10,17 @@ ______________________________________________________________________
Notes for GoldED+ 1.1.5, /snapshot/ Notes for GoldED+ 1.1.5, /snapshot/
______________________________________________________________________ ______________________________________________________________________
- Relative path usage is fixed. Now a Real UID is used to parse "~/" always.
+ Several unicode charset convertion tables is included into distribution of + Several unicode charset convertion tables is included into distribution of
the config examples. the config examples.
+ Relative path may be used for patchnames definiions in config. User's home + Gedlnx: Relative path may be used for patchnames definiions in config.
directory (~/) may be used in unixes. Example: User's home directory (~/) may be used in unixes. Examples:
include ~/golded.cfg ; include the user-specific subconfig include ~/golded.cfg ; include the user-specific subconfig of current user
include ~fido/configs/golded.cfg ; include specific subconfig of user fido
seqdir ~fido ; specify MSGID-sequence store path to /home/fido/
! Temporarily disabled the AreaRecycleBin. ! Temporarily disabled the AreaRecycleBin.

View File

@ -317,11 +317,9 @@ void TouchFile(const char* filename) {
char* PathCopy(char* __dst, const char* __src) { char* PathCopy(char* __dst, const char* __src) {
strschg_environ(strxcpy(__dst, __src, sizeof(Path))); strschg_environ(strxcpy(__dst, __src, sizeof(Path)));
getcwd(__dst, sizeof(Path)); // expand ~/ & etc.
return AddBackslash(__dst); return AddBackslash(__dst);
} }
// ------------------------------------------------------------------ // ------------------------------------------------------------------
int TestLockPath(const char* __path) { int TestLockPath(const char* __path) {

View File

@ -77,7 +77,7 @@ int strschg_environ(std::string& s) {
size_t posn, posn1; size_t posn, posn1;
while(((posn=s.find('%')) != s.npos) and ((posn1=s.find('%', posn+1)) != s.npos)) { while(((posn=s.find('%')) != s.npos) and ((posn1=s.find('%', posn+1)) != s.npos)) {
fnd = s.substr(posn+1, posn1-1); fnd = s.substr(posn+1, posn1-1);
const char* rep = getenv(fnd.c_str()); const char* rep = getenv(fnd.c_str());
rep = rep ? rep : ""; rep = rep ? rep : "";
s.replace(posn, posn1-posn+1, rep); s.replace(posn, posn1-posn+1, rep);
@ -89,16 +89,16 @@ int strschg_environ(std::string& s) {
std::string name; std::string name;
char* lname; char* lname;
const char *p = s.c_str()+1; const char *p = s.c_str()+1;
struct passwd *pe=NULL;
if((s.length() != 1) and not isslash(*p)) { if((s.length() != 1) and not isslash(*p)) {
while(*p and not isslash(*p)) while(*p and not isslash(*p))
name += *p++; name += *p++;
pe = getpwnam(name.c_str());
} }
else { else {
if ((lname = getlogin()) == NULL) pe = getpwuid(getuid());
lname = getenv("LOGNAME");
name = lname;
} }
struct passwd *pe = getpwnam(name.c_str());
if(pe != NULL) { if(pe != NULL) {
std::string dirname = pe->pw_dir; std::string dirname = pe->pw_dir;
dirname += "/"; dirname += "/";
@ -161,7 +161,7 @@ bool maketruepath(std::string &dirname) {
else { else {
dirname = cwd; dirname = cwd;
ok = false; ok = false;
} }
#else #else
long inspos = -1; long inspos = -1;
if((dirname.length() == 2) and (dirname[1] == ':')) if((dirname.length() == 2) and (dirname[1] == ':'))