summaryrefslogtreecommitdiff
path: root/src/VBox/Runtime/common/vfs
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2014-03-26 19:21:20 +0000
committer <>2014-05-08 15:03:54 +0000
commitfb123f93f9f5ce42c8e5785d2f8e0edaf951740e (patch)
treec2103d76aec5f1f10892cd1d3a38e24f665ae5db /src/VBox/Runtime/common/vfs
parent58ed4748338f9466599adfc8a9171280ed99e23f (diff)
downloadVirtualBox-master.tar.gz
Imported from /home/lorry/working-area/delta_VirtualBox/VirtualBox-4.3.10.tar.bz2.HEADVirtualBox-4.3.10master
Diffstat (limited to 'src/VBox/Runtime/common/vfs')
-rw-r--r--src/VBox/Runtime/common/vfs/vfsbase.cpp2
-rw-r--r--src/VBox/Runtime/common/vfs/vfschain.cpp12
-rw-r--r--src/VBox/Runtime/common/vfs/vfsmisc.cpp2
-rw-r--r--src/VBox/Runtime/common/vfs/vfsstdfile.cpp71
4 files changed, 64 insertions, 23 deletions
diff --git a/src/VBox/Runtime/common/vfs/vfsbase.cpp b/src/VBox/Runtime/common/vfs/vfsbase.cpp
index 49984513..8e38715b 100644
--- a/src/VBox/Runtime/common/vfs/vfsbase.cpp
+++ b/src/VBox/Runtime/common/vfs/vfsbase.cpp
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2010 Oracle Corporation
+ * Copyright (C) 2010-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/src/VBox/Runtime/common/vfs/vfschain.cpp b/src/VBox/Runtime/common/vfs/vfschain.cpp
index 0017cf38..2e43b261 100644
--- a/src/VBox/Runtime/common/vfs/vfschain.cpp
+++ b/src/VBox/Runtime/common/vfs/vfschain.cpp
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2010 Oracle Corporation
+ * Copyright (C) 2010-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -63,13 +63,11 @@ static RTLISTANCHOR g_rtVfsChainElementProviderList;
* Initializes the globals via RTOnce.
*
* @returns IPRT status code
- * @param pvUser1 Unused, ignored.
- * @param pvUser2 Unused, ignored.
+ * @param pvUser Unused, ignored.
*/
-static DECLCALLBACK(int) rtVfsChainElementRegisterInit(void *pvUser1, void *pvUser2)
+static DECLCALLBACK(int) rtVfsChainElementRegisterInit(void *pvUser)
{
- NOREF(pvUser1);
- NOREF(pvUser2);
+ NOREF(pvUser);
return RTCritSectInit(&g_rtVfsChainElementCritSect);
}
@@ -97,7 +95,7 @@ RTDECL(int) RTVfsChainElementRegisterProvider(PRTVFSCHAINELEMENTREG pRegRec, boo
*/
if (!fFromCtor)
{
- rc = RTOnce(&g_rtVfsChainElementInitOnce, rtVfsChainElementRegisterInit, NULL, NULL);
+ rc = RTOnce(&g_rtVfsChainElementInitOnce, rtVfsChainElementRegisterInit, NULL);
if (RT_FAILURE(rc))
return rc;
rc = RTCritSectEnter(&g_rtVfsChainElementCritSect);
diff --git a/src/VBox/Runtime/common/vfs/vfsmisc.cpp b/src/VBox/Runtime/common/vfs/vfsmisc.cpp
index f35005d3..1f353fb0 100644
--- a/src/VBox/Runtime/common/vfs/vfsmisc.cpp
+++ b/src/VBox/Runtime/common/vfs/vfsmisc.cpp
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2010 Oracle Corporation
+ * Copyright (C) 2010-2011 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/src/VBox/Runtime/common/vfs/vfsstdfile.cpp b/src/VBox/Runtime/common/vfs/vfsstdfile.cpp
index 8b01af67..5f023e74 100644
--- a/src/VBox/Runtime/common/vfs/vfsstdfile.cpp
+++ b/src/VBox/Runtime/common/vfs/vfsstdfile.cpp
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2010 Oracle Corporation
+ * Copyright (C) 2010-2011 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -418,6 +418,31 @@ DECL_HIDDEN_CONST(const RTVFSFILEOPS) g_rtVfsStdFileOps =
};
+/**
+ * Internal worker for RTVfsFileFromRTFile and RTVfsFileOpenNormal.
+ *
+ * @returns IRPT status code.
+ * @param hFile The IPRT file handle.
+ * @param fOpen The RTFILE_O_XXX flags.
+ * @param fLeaveOpen Whether to leave it open or close it.
+ * @param phVfsFile Where to return the handle.
+ */
+static int rtVfsFileFromRTFile(RTFILE hFile, uint64_t fOpen, bool fLeaveOpen, PRTVFSFILE phVfsFile)
+{
+ PRTVFSSTDFILE pThis;
+ RTVFSFILE hVfsFile;
+ int rc = RTVfsNewFile(&g_rtVfsStdFileOps, sizeof(RTVFSSTDFILE), fOpen, NIL_RTVFS, NIL_RTVFSLOCK,
+ &hVfsFile, (void **)&pThis);
+ if (RT_FAILURE(rc))
+ return rc;
+
+ pThis->hFile = hFile;
+ pThis->fLeaveOpen = fLeaveOpen;
+ *phVfsFile = hVfsFile;
+ return VINF_SUCCESS;
+}
+
+
RTDECL(int) RTVfsFileFromRTFile(RTFILE hFile, uint64_t fOpen, bool fLeaveOpen, PRTVFSFILE phVfsFile)
{
/*
@@ -429,28 +454,36 @@ RTDECL(int) RTVfsFileFromRTFile(RTFILE hFile, uint64_t fOpen, bool fLeaveOpen, P
return rc;
/*
- * Set up some fake fOpen flags.
+ * Set up some fake fOpen flags if necessary and create a VFS file handle.
*/
if (!fOpen)
fOpen = RTFILE_O_READWRITE | RTFILE_O_DENY_NONE | RTFILE_O_OPEN_CREATE;
+ return rtVfsFileFromRTFile(hFile, fOpen, fLeaveOpen, phVfsFile);
+}
+
+
+RTDECL(int) RTVfsFileOpenNormal(const char *pszFilename, uint64_t fOpen, PRTVFSFILE phVfsFile)
+{
/*
- * Create the handle.
+ * Open the file the normal way and pass it to RTVfsFileFromRTFile.
*/
- PRTVFSSTDFILE pThis;
- RTVFSFILE hVfsFile;
- rc = RTVfsNewFile(&g_rtVfsStdFileOps, sizeof(RTVFSSTDFILE), fOpen, NIL_RTVFS, NIL_RTVFSLOCK, &hVfsFile, (void **)&pThis);
- if (RT_FAILURE(rc))
- return rc;
-
- pThis->hFile = hFile;
- pThis->fLeaveOpen = fLeaveOpen;
- *phVfsFile = hVfsFile;
- return VINF_SUCCESS;
+ RTFILE hFile;
+ int rc = RTFileOpen(&hFile, pszFilename, fOpen);
+ if (RT_SUCCESS(rc))
+ {
+ /*
+ * Create a VFS file handle.
+ */
+ rc = rtVfsFileFromRTFile(hFile, fOpen, false /*fLeaveOpen*/, phVfsFile);
+ if (RT_FAILURE(rc))
+ RTFileClose(hFile);
+ }
+ return rc;
}
-RTDECL(int) RTVfsIoStrmFromRTFile(RTFILE hFile, uint64_t fOpen, bool fLeaveOpen, PRTVFSIOSTREAM phVfsIos)
+RTDECL(int) RTVfsIoStrmFromRTFile(RTFILE hFile, uint64_t fOpen, bool fLeaveOpen, PRTVFSIOSTREAM phVfsIos)
{
RTVFSFILE hVfsFile;
int rc = RTVfsFileFromRTFile(hFile, fOpen, fLeaveOpen, &hVfsFile);
@@ -459,3 +492,13 @@ RTDECL(int) RTVfsIoStrmFromRTFile(RTFILE hFile, uint64_t fOpen, bool fLe
return rc;
}
+
+RTDECL(int) RTVfsIoStrmOpenNormal(const char *pszFilename, uint64_t fOpen, PRTVFSIOSTREAM phVfsIos)
+{
+ RTVFSFILE hVfsFile;
+ int rc = RTVfsFileOpenNormal(pszFilename, fOpen, &hVfsFile);
+ if (RT_SUCCESS(rc))
+ *phVfsIos = RTVfsFileToIoStream(hVfsFile);
+ return rc;
+}
+