\begin{funcdesc}{fsync}{fd}
Force write of file with filedescriptor \var{fd} to disk.
-Availability: \UNIX.
+
+On Windows this calls the MS \cfunction{_commit()} function. If you're
+starting with a Python file object \var{f}, first do
+\code{\var{f}.flush()}, and then do \code{os.fsync(\var{f}.fileno()},
+to ensure that all internal buffers associated with \var{f} are written
+to disk.
+Availability: \UNIX, and Windows starting in 2.3.
\end{funcdesc}
\begin{funcdesc}{ftruncate}{fd, length}
\member{st_atime},
\member{st_mtime},
\member{st_ctime}.
-More items may be added at the end by some implementations.
+More items may be added at the end by some implementations.
The standard module \refmodule{stat}\refstmodindex{stat} defines
functions and constants that are useful for extracting information
from a \ctype{stat} structure.
#define HAVE_POPEN 1
#define HAVE_SYSTEM 1
#define HAVE_CWAIT 1
+#define HAVE_FSYNC 1
+#define fsync _commit
#else
#if defined(PYOS_OS2) && defined(PYCC_GCC) || defined(__VMS)
/* Everything needed is defined in PC/os2emx/pyconfig.h or vms/pyconfig.h */
# define STRUCT_STAT struct stat
#endif
-#if defined(MAJOR_IN_MKDEV)
+#if defined(MAJOR_IN_MKDEV)
#include <sys/mkdev.h>
#else
#if defined(MAJOR_IN_SYSMACROS)
#if defined(__VMS)
/* add some values to provide a similar environment like POSIX */
-static
+static
void
vms_add_posix_env(PyObject *d)
{
return PyUnicode_FromUnicode(PyUnicode_AS_UNICODE(obj),
PyUnicode_GET_SIZE(obj));
}
- return PyUnicode_FromEncodedObject(obj,
- Py_FileSystemDefaultEncoding,
+ return PyUnicode_FromEncodedObject(obj,
+ Py_FileSystemDefaultEncoding,
"strict");
}
}
#ifdef Py_WIN_WIDE_FILENAMES
-static int
+static int
unicode_file_names(void)
{
static int canusewide = -1;
if (canusewide == -1) {
- /* As per doc for ::GetVersion(), this is the correct test for
+ /* As per doc for ::GetVersion(), this is the correct test for
the Windows NT family. */
canusewide = (GetVersion() < 0x80000000) ? 1 : 0;
}
return canusewide;
}
#endif
-
+
static PyObject *
posix_1str(PyObject *args, char *format, int (*func)(const char*),
char *wformat, int (*wfunc)(const Py_UNICODE*))
}
static PyObject *
-posix_2str(PyObject *args,
+posix_2str(PyObject *args,
char *format,
int (*func)(const char *, const char *),
char *wformat,
}
static PyObject *
-posix_do_stat(PyObject *self, PyObject *args,
+posix_do_stat(PyObject *self, PyObject *args,
char *format,
#ifdef __VMS
int (*statfunc)(const char *, STRUCT_STAT *, ...),
#elif defined(PYOS_OS2) && defined(PYCC_GCC)
return posix_1str(args, "et:chdir", _chdir2, NULL, NULL);
#elif defined(__VMS)
- return posix_1str(args, "et:chdir", (int (*)(const char *))chdir,
+ return posix_1str(args, "et:chdir", (int (*)(const char *))chdir,
NULL, NULL);
#else
return posix_1str(args, "et:chdir", chdir, NULL, NULL);
Py_BEGIN_ALLOW_THREADS
res = lchown(path, (uid_t) uid, (gid_t) gid);
Py_END_ALLOW_THREADS
- if (res < 0)
+ if (res < 0)
return posix_error_with_allocated_filename(path);
PyMem_Free(path);
Py_INCREF(Py_None);
PyObject *w;
w = PyUnicode_FromEncodedObject(v,
- Py_FileSystemDefaultEncoding,
+ Py_FileSystemDefaultEncoding,
"strict");
if (w != NULL) {
Py_DECREF(v);
if (PyArg_ParseTuple(args, "U|:_getfullpathname", &po)) {
Py_UNICODE woutbuf[MAX_PATH*2];
Py_UNICODE *wtemp;
- if (!GetFullPathNameW(PyUnicode_AS_UNICODE(po),
+ if (!GetFullPathNameW(PyUnicode_AS_UNICODE(po),
sizeof(woutbuf)/sizeof(woutbuf[0]),
woutbuf, &wtemp))
return win32_error("GetFullPathName", "");
/*
* Variation on os2emx.popen2
*
- * The result of this function is 2 pipes - the processes stdin,
+ * The result of this function is 2 pipes - the processes stdin,
* and stdout+stderr combined as a single pipe.
*/
}
}
}
-
+
/*
* Clean up our localized references for the dictionary keys
* and value since PyDict_SetItem will Py_INCREF any copies
s3,
cmdstring);
/* Not passing CREATE_NEW_CONSOLE has been known to
- cause random failures on win9x. Specifically a
+ cause random failures on win9x. Specifically a
dialog:
"Your program accessed mem currently in use at xxx"
and a hopeful warning about the stability of your