summaryrefslogtreecommitdiff
path: root/core/src/fxcrt/fx_extension.cpp
diff options
context:
space:
mode:
authorBo Xu <bo_xu@foxitsoftware.com>2014-10-28 23:03:33 -0700
committerBo Xu <bo_xu@foxitsoftware.com>2014-11-03 11:10:11 -0800
commitfdc00a7042d912aafaabddae4d9c84199921ef23 (patch)
tree32ab8ac91cc68d2cd15b9168782a71b3f3f5e7b9 /core/src/fxcrt/fx_extension.cpp
parente9b38fa38de2c95d8260be31c57d9272c4d127ed (diff)
downloadpdfium-fdc00a7042d912aafaabddae4d9c84199921ef23.tar.xz
Merge XFA to PDFium master at 4dc95e7 on 10/28/2014
Diffstat (limited to 'core/src/fxcrt/fx_extension.cpp')
-rw-r--r--core/src/fxcrt/fx_extension.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/core/src/fxcrt/fx_extension.cpp b/core/src/fxcrt/fx_extension.cpp
index 7ff6b062b4..330c675457 100644
--- a/core/src/fxcrt/fx_extension.cpp
+++ b/core/src/fxcrt/fx_extension.cpp
@@ -80,6 +80,18 @@ FX_BOOL FX_File_Truncate(FX_HFILE hFile, FX_FILESIZE szFile)
FXSYS_assert(hFile != NULL);
return ((IFXCRT_FileAccess*)hFile)->Truncate(szFile);
}
+IFX_FileAccess* FX_CreateDefaultFileAccess(FX_WSTR wsPath)
+{
+ if (wsPath.GetLength() == 0)
+ return NULL;
+
+ CFX_CRTFileAccess* pFA = NULL;
+ pFA = FX_NEW CFX_CRTFileAccess;
+ if (NULL == pFA) return NULL;
+
+ pFA->Init(wsPath);
+ return pFA;
+}
IFX_FileStream* FX_CreateFileStream(FX_LPCSTR filename, FX_DWORD dwModes)
{
IFXCRT_FileAccess* pFA = FXCRT_FileAccess_Create();
@@ -383,3 +395,40 @@ void FX_Random_GenerateCrypto(FX_LPDWORD pBuffer, FX_INT32 iCount)
#ifdef __cplusplus
}
#endif
+#ifdef __cplusplus
+extern "C" {
+#endif
+void FX_GUID_CreateV4(FX_LPGUID pGUID)
+{
+#if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || _FX_OS_ == _FX_WIN64_)
+#ifdef _FX_WINAPI_PARTITION_DESKTOP_
+ if (!FX_GenerateCryptoRandom((FX_LPDWORD)pGUID, 4)) {
+ FX_Random_GenerateMT((FX_LPDWORD)pGUID, 4);
+ }
+#else
+ FX_Random_GenerateMT((FX_LPDWORD)pGUID, 4);
+#endif
+#else
+ FX_Random_GenerateMT((FX_LPDWORD)pGUID, 4);
+#endif
+ FX_BYTE &b = ((FX_LPBYTE)pGUID)[6];
+ b = (b & 0x0F) | 0x40;
+}
+FX_LPCSTR gs_FX_pHexChars = "0123456789ABCDEF";
+void FX_GUID_ToString(FX_LPCGUID pGUID, CFX_ByteString &bsStr, FX_BOOL bSeparator)
+{
+ FX_LPSTR pBuf = bsStr.GetBuffer(40);
+ FX_BYTE b;
+ for (FX_INT32 i = 0; i < 16; i ++) {
+ b = ((FX_LPCBYTE)pGUID)[i];
+ *pBuf ++ = gs_FX_pHexChars[b >> 4];
+ *pBuf ++ = gs_FX_pHexChars[b & 0x0F];
+ if (bSeparator && (i == 3 || i == 5 || i == 7 || i == 9)) {
+ *pBuf ++ = L'-';
+ }
+ }
+ bsStr.ReleaseBuffer(bSeparator ? 36 : 32);
+}
+#ifdef __cplusplus
+}
+#endif