projects
/
silc.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merged from silc_1_0_branch.
[silc.git]
/
lib
/
silcutil
/
silcfileutil.c
diff --git
a/lib/silcutil/silcfileutil.c
b/lib/silcutil/silcfileutil.c
index 7d2d14757281af64b6f1e7ae737fa72ed1cd7fe6..52112ee3903bac053bcdffd982b34faa6e2ff128 100644
(file)
--- a/
lib/silcutil/silcfileutil.c
+++ b/
lib/silcutil/silcfileutil.c
@@
-65,8
+65,13
@@
int silc_file_writefile(const char *filename, const char *buffer,
SilcUInt32 len)
{
int fd;
SilcUInt32 len)
{
int fd;
+ int flags = O_CREAT | O_WRONLY | O_TRUNC;
- if ((fd = creat(filename, 0644)) == -1) {
+#if defined(O_BINARY)
+ flags |= O_BINARY;
+#endif /* O_BINARY */
+
+ if ((fd = open(filename, flags, 0644)) == -1) {
SILC_LOG_ERROR(("Cannot open file %s for writing: %s", filename,
strerror(errno)));
return -1;
SILC_LOG_ERROR(("Cannot open file %s for writing: %s", filename,
strerror(errno)));
return -1;
@@
-90,8
+95,13
@@
int silc_file_writefile_mode(const char *filename, const char *buffer,
SilcUInt32 len, int mode)
{
int fd;
SilcUInt32 len, int mode)
{
int fd;
+ int flags = O_CREAT | O_WRONLY | O_TRUNC;
+
+#if defined(O_BINARY)
+ flags |= O_BINARY;
+#endif /* O_BINARY */
- if ((fd =
creat(filename, mode
)) == -1) {
+ if ((fd =
open(filename, flags, 0644
)) == -1) {
SILC_LOG_ERROR(("Cannot open file %s for writing: %s", filename,
strerror(errno)));
return -1;
SILC_LOG_ERROR(("Cannot open file %s for writing: %s", filename,
strerror(errno)));
return -1;