#include <sys/mount.h>
#endif
#include <sys/types.h>
-#include <dirent.h>
-#include <fnmatch.h>
#include <stdio.h>
#include <utime.h>
#ifdef __linux__
struct _WapiHandle_file *file_handle;
gboolean ok;
struct stat statbuf;
- off_t size, pos;
+ off_t pos;
int ret, fd;
ok=_wapi_lookup_handle (handle, WAPI_HANDLE_FILE,
_wapi_set_last_error_from_errno ();
return(FALSE);
}
- size=statbuf.st_size;
pos=lseek(fd, (off_t)0, SEEK_CUR);
if(pos==-1) {
}
#ifdef FTRUNCATE_DOESNT_EXTEND
+ off_t size = statbuf.st_size;
/* I haven't bothered to write the configure.ac stuff for this
* because I don't know if any platform needs it. I'm leaving
* this code just in case though
DEBUG("%s: closing console handle %p", __func__, handle);
g_free (console_handle->filename);
-
- close (fd);
+
+ if (fd > 2)
+ close (fd);
}
static WapiFileType console_getfiletype(void)
* catch that case here.
*/
if (attrs & FILE_ATTRIBUTE_READONLY) {
- result = _wapi_chmod (utf8_name, buf.st_mode & ~(S_IWRITE | S_IWOTH | S_IWGRP));
+ result = _wapi_chmod (utf8_name, buf.st_mode & ~(S_IWUSR | S_IWOTH | S_IWGRP));
} else {
- result = _wapi_chmod (utf8_name, buf.st_mode | S_IWRITE);
+ result = _wapi_chmod (utf8_name, buf.st_mode | S_IWUSR);
}
/* Ignore the other attributes for now */
return(TRUE);
}
-guint32 GetTempPath (guint32 len, gunichar2 *buf)
-{
- gchar *tmpdir=g_strdup (g_get_tmp_dir ());
- gunichar2 *tmpdir16=NULL;
- glong dirlen;
- gsize bytes;
- guint32 ret;
-
- if(tmpdir[strlen (tmpdir)]!='/') {
- g_free (tmpdir);
- tmpdir=g_strdup_printf ("%s/", g_get_tmp_dir ());
- }
-
- tmpdir16=mono_unicode_from_external (tmpdir, &bytes);
- if(tmpdir16==NULL) {
- g_free (tmpdir);
- return(0);
- } else {
- dirlen=(bytes/2);
-
- if(dirlen+1>len) {
- DEBUG ("%s: Size %d smaller than needed (%ld)",
- __func__, len, dirlen+1);
-
- ret=dirlen+1;
- } else {
- /* Add the terminator */
- memset (buf, '\0', bytes+2);
- memcpy (buf, tmpdir16, bytes);
-
- ret=dirlen;
- }
- }
-
- if(tmpdir16!=NULL) {
- g_free (tmpdir16);
- }
- g_free (tmpdir);
-
- return(ret);
-}
-
#ifdef HAVE_GETFSSTAT
/* Darwin has getfsstat */
gint32 GetLogicalDriveStrings (guint32 len, gunichar2 *buf)
}
#endif
-#if (defined(HAVE_STATVFS) || defined(HAVE_STATFS)) && !defined(PLATFORM_ANDROID)
+#if defined(HAVE_STATVFS) || defined(HAVE_STATFS)
gboolean GetDiskFreeSpaceEx(const gunichar2 *path_name, WapiULargeInteger *free_bytes_avail,
WapiULargeInteger *total_number_of_bytes,
WapiULargeInteger *total_number_of_free_bytes)
block_size = fsstat.f_frsize;
#elif defined(HAVE_STATFS)
ret = statfs (utf8_path_name, &fsstat);
+#if defined (MNT_RDONLY)
isreadonly = ((fsstat.f_flags & MNT_RDONLY) == MNT_RDONLY);
+#elif defined (MS_RDONLY)
+ isreadonly = ((fsstat.f_flags & MS_RDONLY) == MS_RDONLY);
+#endif
block_size = fsstat.f_bsize;
#endif
} while(ret == -1 && errno == EINTR);
return (drive_type);
}
+#if defined (PLATFORM_MACOSX) || defined (__linux__) || defined(PLATFORM_BSD) || defined(__native_client__) || defined(__FreeBSD_kernel__)
static gchar*
get_fstypename (gchar *utfpath)
{
}
/* Linux has struct statfs which has a different layout */
-#if defined (PLATFORM_MACOSX) || defined (__linux__) || defined(PLATFORM_BSD) || defined(__native_client__)
gboolean
GetVolumeInformation (const gunichar2 *path, gunichar2 *volumename, int volumesize, int *outserial, int *maxcomp, int *fsflags, gunichar2 *fsbuffer, int fsbuffersize)
{