[vlc-commits] src: add vlc_close() wrapper
Rémi Denis-Courmont
git at videolan.org
Thu Apr 21 23:18:00 CEST 2016
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri Apr 22 00:11:34 2016 +0300| [582355f9654ab8bbdc9069738c47d8e55664afd7] | committer: Rémi Denis-Courmont
src: add vlc_close() wrapper
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=582355f9654ab8bbdc9069738c47d8e55664afd7
---
include/vlc_fs.h | 22 ++++++++++++++++++++++
src/os2/filesystem.c | 5 +++++
src/posix/filesystem.c | 5 +++++
src/win32/filesystem.c | 5 +++++
4 files changed, 37 insertions(+)
diff --git a/include/vlc_fs.h b/include/vlc_fs.h
index 69bd743..8fda513 100644
--- a/include/vlc_fs.h
+++ b/include/vlc_fs.h
@@ -140,6 +140,28 @@ VLC_API ssize_t vlc_write(int, const void *, size_t);
VLC_API ssize_t vlc_writev(int, const struct iovec *, int);
/**
+ * Closes a file descriptor.
+ *
+ * This closes a file descriptor. If this is a last file descriptor for the
+ * underlying open file, the file is closed too; the exact semantics depend
+ * on the type of file.
+ *
+ * @note The file descriptor is always closed when the function returns, even
+ * if the function returns an error. The sole exception is if the file
+ * descriptor was not currently valid, and thus cannot be closed (errno will
+ * then be set to EBADF).
+ *
+ * @param fd file descriptor
+ * @return Normally, zero is returned.
+ * If an I/O error is detected before or while closing, the function may return
+ * -1. Such an error is unrecoverable since the descriptor is closed.
+ *
+ * A nul return value does not necessarily imply that all pending I/O
+ * succeeded, since I/O might still occur asynchronously afterwards.
+ */
+VLC_API int vlc_close(int fd);
+
+/**
* @}
*/
diff --git a/src/os2/filesystem.c b/src/os2/filesystem.c
index 256b9cc..bbb4ab3 100644
--- a/src/os2/filesystem.c
+++ b/src/os2/filesystem.c
@@ -86,6 +86,11 @@ int vlc_memfd (void)
return -1;
}
+int vlc_close (int fd)
+{
+ return close (fd);
+}
+
int vlc_mkdir (const char *dirname, mode_t mode)
{
char *locname = ToLocaleDup (dirname);
diff --git a/src/posix/filesystem.c b/src/posix/filesystem.c
index a0536e0..dd516e1 100644
--- a/src/posix/filesystem.c
+++ b/src/posix/filesystem.c
@@ -132,6 +132,11 @@ int vlc_memfd (void)
return fd;
}
+int vlc_close (int fd)
+{
+ return close (fd);
+}
+
int vlc_mkdir (const char *dirname, mode_t mode)
{
return mkdir (dirname, mode);
diff --git a/src/win32/filesystem.c b/src/win32/filesystem.c
index f05aa5d5..29a7a3f 100644
--- a/src/win32/filesystem.c
+++ b/src/win32/filesystem.c
@@ -124,6 +124,11 @@ int vlc_memfd (void)
#endif
}
+int vlc_close (int fd)
+{
+ return close (fd);
+}
+
int vlc_mkdir( const char *dirname, mode_t mode )
{
wchar_t *wpath = widen_path (dirname);
More information about the vlc-commits
mailing list