udpates.
[silc.git] / lib / silcutil / silcutil.c
index 9d1ab991b5311cdb6157913aafa8da8b4a57b660..0ee0dd6816e15f64e4e22cdd1b9ce236b4329dc7 100644 (file)
@@ -32,7 +32,7 @@ int silc_file_open(const char *filename, int flags)
 {
   int fd;
 
-  fd = open(filename, flags);
+  fd = open(filename, flags, 0600);
 
   return fd;
 }
@@ -158,6 +158,20 @@ char *silc_file_readfile(const char *filename, uint32 *return_len)
   return buffer;
 }
 
+/* Returns files size. Returns 0 on error. */
+
+uint64 silc_file_size(const char *filename)
+{
+  int ret;
+  struct stat stats;
+
+  ret = lstat(filename, &stats);
+  if (ret < 0)
+    return 0;
+
+  return (uint64)stats.st_size;
+}
+
 /* Gets line from a buffer. Stops reading when a newline or EOF occurs.
    This doesn't remove the newline sign from the destination buffer. The
    argument begin is returned and should be passed again for the function. */