projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
intern: Use UP_CAST macro instad of open-coding it.
[pspp]
/
src
/
language
/
utilities
/
permissions.c
diff --git
a/src/language/utilities/permissions.c
b/src/language/utilities/permissions.c
index 83fa820c562d3be6473ef70afa49dd95a5b6ecc6..8b0e3f0c31926862e1135464460a30fccee3ca50 100644
(file)
--- a/
src/language/utilities/permissions.c
+++ b/
src/language/utilities/permissions.c
@@
-25,6
+25,7
@@
#include "data/settings.h"
#include "language/command.h"
#include "language/lexer/lexer.h"
#include "data/settings.h"
#include "language/command.h"
#include "language/lexer/lexer.h"
+#include "libpspp/i18n.h"
#include "libpspp/message.h"
#include "libpspp/misc.h"
#include "libpspp/str.h"
#include "libpspp/message.h"
#include "libpspp/misc.h"
#include "libpspp/str.h"
@@
-94,20
+95,23
@@
cmd_permissions (struct lexer *lexer, struct dataset *ds UNUSED)
int
change_permissions (const char *file_name, enum PER per)
{
int
change_permissions (const char *file_name, enum PER per)
{
+ char *locale_file_name;
struct stat buf;
mode_t mode;
if (settings_get_safer_mode ())
{
msg (SE, _("This command not allowed when the SAFER option is set."));
struct stat buf;
mode_t mode;
if (settings_get_safer_mode ())
{
msg (SE, _("This command not allowed when the SAFER option is set."));
- return
CMD_FAILURE
;
+ return
0
;
}
}
- if ( -1 == stat(file_name, &buf) )
+ locale_file_name = utf8_to_filename (file_name);
+ if ( -1 == stat(locale_file_name, &buf) )
{
const int errnum = errno;
msg (SE, _("Cannot stat %s: %s"), file_name, strerror(errnum));
{
const int errnum = errno;
msg (SE, _("Cannot stat %s: %s"), file_name, strerror(errnum));
+ free (locale_file_name);
return 0;
}
return 0;
}
@@
-116,13
+120,16
@@
change_permissions (const char *file_name, enum PER per)
else
mode = buf.st_mode & ~0222;
else
mode = buf.st_mode & ~0222;
- if ( -1 == chmod(file_name, mode))
+ if ( -1 == chmod(
locale_
file_name, mode))
{
const int errnum = errno;
msg (SE, _("Cannot change mode of %s: %s"), file_name, strerror(errnum));
{
const int errnum = errno;
msg (SE, _("Cannot change mode of %s: %s"), file_name, strerror(errnum));
+ free (locale_file_name);
return 0;
}
return 0;
}
+ free (locale_file_name);
+
return 1;
}
return 1;
}