"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/xfeutils.cpp" between
xfe-1.41.tar.gz and xfe-1.42.tar.gz

About: Xfe (X File Explorer) is a file manager and browser (using the FOX toolkit).

xfeutils.cpp  (xfe-1.41):xfeutils.cpp  (xfe-1.42)
skipping to change at line 21 skipping to change at line 21
#include <time.h> #include <time.h>
#include <libgen.h> #include <libgen.h>
#include <fx.h> #include <fx.h>
#include <fxkeys.h> #include <fxkeys.h>
#include <FXPNGIcon.h> #include <FXPNGIcon.h>
#include "xfedefs.h" #include "xfedefs.h"
#include "icons.h" #include "icons.h"
#include "xfeutils.h" #include "xfeutils.h"
#include "../st/st.h"
// Decode filename to get original again // Decode filename to get original again
FXString FXPath::dequote(const FXString& file) FXString FXPath::dequote(const FXString& file)
{ {
FXString result(file); FXString result(file);
if (0 < result.length()) if (0 < result.length())
{ {
register FXint e = result.length(); register int e = result.length();
register FXint b = 0; register int b = 0;
register FXint r = 0; register int r = 0;
register FXint q = 0; register int q = 0;
// Trim tail // Trim tail
while (0 < e && Ascii::isSpace(result[e-1])) while (0 < e && Ascii::isSpace(result[e-1]))
{ {
--e; --e;
} }
// Trim head // Trim head
while (b < e && Ascii::isSpace(result[b])) while (b < e && Ascii::isSpace(result[b]))
{ {
skipping to change at line 266 skipping to change at line 267
} }
// Simple command name or path relative to the exec path // Simple command name or path relative to the exec path
else else
{ {
// Get exec path // Get exec path
FXString execpath = FXSystem::getExecPath(); FXString execpath = FXSystem::getExecPath();
if (execpath != "") if (execpath != "")
{ {
FXString path; // Number of delimiters
int nbseps = execpath.contains(':');
for (int i = 0; ; i++) // Loop over path components
for (int i = 0; i <= nbseps; i++)
{ {
// Obtain path component // Obtain path component
path = execpath.section(':', i); FXString path = execpath.section(':', i);
if (path == "")
{
break;
}
// Form command absolute path // Form command absolute path
path += PATHSEPSTRING + cmdpath; path += PATHSEPSTRING + cmdpath;
// Check if command file name exists and is not a directory // Check if command file name exists and is not a directory
if (!path.empty() && (lstatrep(path.text(), &linfo) == 0) && !S_ ISDIR(linfo.st_mode)) if (!path.empty() && (lstatrep(path.text(), &linfo) == 0) && !S_ ISDIR(linfo.st_mode))
{ {
return(true); return(true);
} }
} }
skipping to change at line 687 skipping to change at line 686
return(true); return(true);
} }
#if defined(linux) #if defined(linux)
// Stat function used to test if a mount point is up or down // Stat function used to test if a mount point is up or down
// Actually, this is simply the lstat() function // Actually, this is simply the lstat() function
int lstatmt(const char* filename, struct stat* buf) int lstatmt(const char* filename, struct stat* buf)
{ {
return(lstat(filename, buf)); return(lstat(filename, buf));
} }
#endif
#if !defined (__OpenBSD__)
// Safe strcpy function (Public domain, by C.B. Falconer) // Safe strcpy function (Public domain, by C.B. Falconer)
// The destination string is always null terminated // The destination string is always null terminated
// Size sz must be equal to strlen(src)+1 // Size sz must be equal to strlen(src)+1
size_t strlcpy(char* dst, const char* src, size_t sz) size_t strlcpy(char* dst, const char* src, size_t sz)
{ {
const char* start = src; const char* start = src;
if (src && sz--) if (src && sz--)
{ {
while ((*dst++ = *src)) while ((*dst++ = *src))
skipping to change at line 725 skipping to change at line 726
} }
return(src - start - 1); return(src - start - 1);
} }
else if (sz) else if (sz)
{ {
*dst = '\0'; *dst = '\0';
} }
return(0); return(0);
} }
#endif
// Safe strcat function (Public domain, by C.B. Falconer) // Safe strcat function (Public domain, by C.B. Falconer)
// The destination string is always null terminated // The destination string is always null terminated
size_t strlcat(char* dst, const char* src, size_t sz) size_t strlcat(char* dst, const char* src, size_t sz)
{ {
char* start = dst; char* start = dst;
while (*dst++) // assumes sz >= strlen(dst) while (*dst++) // assumes sz >= strlen(dst)
{ {
if (sz) if (sz)
{ {
sz--; // i.e. well formed string sz--; // i.e. well formed string
} }
} }
dst--; dst--;
return(dst - start + strlcpy(dst, src, sz)); return(dst - start + strlcpy(dst, src, sz));
} }
#endif
// Obtain the non recursive size of a directory // Obtain the non recursive size of a directory
FXulong dirsize(const char* path) FXulong dirsize(const char* path)
{ {
DIR* dp; DIR* dp;
struct dirent* dirp; struct dirent* dirp;
struct stat statbuf; struct stat statbuf;
char buf[MAXPATHLEN]; char buf[MAXPATHLEN];
FXulong dsize = 0; FXulong dsize = 0;
int ret; int ret;
skipping to change at line 1529 skipping to change at line 1529
} }
// Other cases : do nothing // Other cases : do nothing
else else
{ {
} }
return(waitcount); return(waitcount);
} }
// Run a command in an internal Xvt terminal // Run a command in an internal st terminal
// Return 0 if success, -1 else // Return 0 if success, -1 else
// N.B.: zombie process should be dealt with in the main application class // N.B.: zombie process should be dealt with in the main application class
int runinxvt(FXString cmd) int runst(FXString cmd)
{ {
FXString str1, str2; FXString str1, str2;
int nbargs, i, j; int nbargs, i, j;
// First pass to find the number of commmand arguments // First pass to find the number of commmand arguments
nbargs = 0; nbargs = 0;
i = 0; i = 0;
j = 1; j = 1;
while (1) while (1)
{ {
skipping to change at line 1599 skipping to change at line 1599
if (streq(str1.text(), "")) if (streq(str1.text(), ""))
{ {
break; break;
} }
i++; i++;
} }
nbargs--; nbargs--;
args[nbargs] = NULL; args[nbargs] = NULL;
// Launch the command in an internal Xvt terminal // Launch the command in an internal st terminal
int res; int res;
static pid_t childpid = 0; static pid_t childpid = 0;
childpid = fork(); childpid = fork();
// Fork succeeded // Fork succeeded
if (childpid >= 0) if (childpid >= 0)
{ {
if (childpid == 0) // Child if (childpid == 0) // Child
{ {
xvt(nbargs, args); st(nbargs, args);
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
else // Parent else // Parent
{ {
// Non blocking wait for child // Non blocking wait for child
if (waitpid(childpid, NULL, WNOHANG) < 0) if (waitpid(childpid, NULL, WNOHANG) < 0)
{ {
res = -1; res = -1;
} }
else else
 End of changes. 13 change blocks. 
17 lines changed or deleted 17 lines changed or added

Home  |  About  |  All  |  Newest  |  Fossies Dox  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTPS