#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)
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)