Line
Link Here
|
0 |
-- frontend/file-selector.cc |
0 |
++ frontend/file-selector.cc |
Lines 35-40
Link Here
|
35 |
#include <cstdio> |
35 |
#include <cstdio> |
36 |
#include <cstdlib> |
36 |
#include <cstdlib> |
37 |
#include <cstring> |
37 |
#include <cstring> |
|
|
38 |
#include <string> |
38 |
#include <unistd.h> |
39 |
#include <unistd.h> |
39 |
|
40 |
|
40 |
#include "pisa_aleart_dialog.h" |
41 |
#include "pisa_aleart_dialog.h" |
Lines 1023-1039
Link Here
|
1023 |
// check write access to the directory (note that we need execute |
1024 |
// check write access to the directory (note that we need execute |
1024 |
// privileges as well) |
1025 |
// privileges as well) |
1025 |
|
1026 |
|
1026 |
char *slash = strrchr( file, '/'); |
1027 |
const char *slash = strrchr( file, '/'); |
1027 |
*slash = '\0'; // temporarily truncate to dirname |
1028 |
std::string dir( file, slash - file); |
1028 |
const char *dir = (file == slash |
1029 |
if (dir.empty()) |
1029 |
? "/" // whoops!, file in root directory |
1030 |
dir = "/"; |
1030 |
: file); |
|
|
1031 |
|
1031 |
|
1032 |
bool w_ok = false; // assume the worst |
1032 |
bool w_ok = false; // assume the worst |
1033 |
if (0 == access( dir, F_OK )) |
1033 |
if (0 == access( dir.c_str(), F_OK )) |
1034 |
w_ok = (0 == access( dir, W_OK | X_OK )); |
1034 |
w_ok = (0 == access( dir.c_str(), W_OK | X_OK )); |
1035 |
|
|
|
1036 |
*slash = '/'; // restore filename |
1037 |
|
1035 |
|
1038 |
return w_ok; |
1036 |
return w_ok; |
1039 |
} |
1037 |
} |
1040 |
-- frontend/pisa_view_manager.cc |
1038 |
++ frontend/pisa_view_manager.cc |
Lines 45-50
Link Here
|
45 |
#include <sys/stat.h> |
45 |
#include <sys/stat.h> |
46 |
#include <dirent.h> |
46 |
#include <dirent.h> |
47 |
#include <locale.h> |
47 |
#include <locale.h> |
|
|
48 |
#include <string> |
48 |
|
49 |
|
49 |
/*------------------------------------------------------------*/ |
50 |
/*------------------------------------------------------------*/ |
50 |
#include "pisa_view_manager.h" |
51 |
#include "pisa_view_manager.h" |
Lines 1170-1179
Link Here
|
1170 |
pisa_file_type |
1171 |
pisa_file_type |
1171 |
view_manager::get_file_type (const char *filename) |
1172 |
view_manager::get_file_type (const char *filename) |
1172 |
{ |
1173 |
{ |
1173 |
char *dot = strrchr (filename, '.'); |
1174 |
const char *dot = strrchr (filename, '.'); |
1174 |
if (!dot) |
1175 |
if (!dot) |
1175 |
{ |
1176 |
{ |
1176 |
char *slash = strrchr (filename, '/'); |
1177 |
const char *slash = strrchr (filename, '/'); |
1177 |
if ( (strlen (slash) == strlen ("/" PACKAGE_TARNAME "XXXXXX")) |
1178 |
if ( (strlen (slash) == strlen ("/" PACKAGE_TARNAME "XXXXXX")) |
1178 |
&& (0 == strncmp (slash, "/" PACKAGE_TARNAME, |
1179 |
&& (0 == strncmp (slash, "/" PACKAGE_TARNAME, |
1179 |
strlen ("/" PACKAGE_TARNAME)))) |
1180 |
strlen ("/" PACKAGE_TARNAME)))) |
Lines 1260-1278
Link Here
|
1260 |
{ |
1261 |
{ |
1261 |
int cancel = 0; // default: don't cancel |
1262 |
int cancel = 0; // default: don't cancel |
1262 |
|
1263 |
|
1263 |
char *slash = strrchr( regexp, '/' ); |
1264 |
const char *slash = strrchr( regexp, '/' ); |
1264 |
|
1265 |
|
1265 |
if (!slash) |
1266 |
if (!slash) |
1266 |
return cancel = 1; |
1267 |
return cancel = 1; |
1267 |
|
1268 |
|
1268 |
*slash = '\0'; // regexp now holds the directory name |
1269 |
std::string s( regexp, slash - regexp); |
1269 |
char dirname[ strlen( regexp )]; |
1270 |
char dirname[ s.size()]; |
1270 |
strcpy( dirname, regexp ); |
1271 |
strcpy( dirname, s.c_str()); |
1271 |
|
1272 |
|
1272 |
*slash = '^'; // re-anchor the regexp |
1273 |
s = std::string("^") + (slash + 1); // re-anchor the regexp |
1273 |
|
1274 |
|
1274 |
regex_t *comp_regex = new regex_t; |
1275 |
regex_t *comp_regex = new regex_t; |
1275 |
int comp = regcomp( comp_regex, slash, REG_EXTENDED ); |
1276 |
int comp = regcomp( comp_regex, s.c_str(), REG_EXTENDED ); |
1276 |
|
1277 |
|
1277 |
if (0 == comp) |
1278 |
if (0 == comp) |
1278 |
{ |
1279 |
{ |
1279 |
-- lib/imgstream.cc |
1280 |
++ lib/imgstream.cc |
Lines 185-191
Link Here
|
185 |
return lt_dlclose (lib); |
185 |
return lt_dlclose (lib); |
186 |
} |
186 |
} |
187 |
|
187 |
|
188 |
static int reversionsort (const void*, const void*); |
188 |
static int reversionsort (const dirent**, const dirent**); |
189 |
int selector (const dirent *); |
189 |
int selector (const dirent *); |
190 |
// forward declarations |
190 |
// forward declarations |
191 |
|
191 |
|
Lines 321-327
Link Here
|
321 |
//! The C library's versionsort() function in reverse. |
321 |
//! The C library's versionsort() function in reverse. |
322 |
static |
322 |
static |
323 |
int |
323 |
int |
324 |
reversionsort (const void *a, const void *b) |
324 |
reversionsort (const dirent **a, const dirent **b) |
325 |
{ |
325 |
{ |
326 |
return versionsort (b, a); |
326 |
return versionsort (b, a); |
327 |
} |
327 |
} |