void FXJSE_ThrowMessage(const CFX_ByteStringC& utf8Name, const CFX_ByteStringC& utf8Message) { v8::Isolate* pIsolate = v8::Isolate::GetCurrent(); ASSERT(pIsolate); CFXJSE_ScopeUtil_IsolateHandleRootContext scope(pIsolate); v8::Local<v8::String> hMessage = v8::String::NewFromUtf8( pIsolate, utf8Message.GetCStr(), v8::String::kNormalString, utf8Message.GetLength()); v8::Local<v8::Value> hError; if (utf8Name == "RangeError") { hError = v8::Exception::RangeError(hMessage); } else if (utf8Name == "ReferenceError") { hError = v8::Exception::ReferenceError(hMessage); } else if (utf8Name == "SyntaxError") { hError = v8::Exception::SyntaxError(hMessage); } else if (utf8Name == "TypeError") { hError = v8::Exception::TypeError(hMessage); } else { hError = v8::Exception::Error(hMessage); if (utf8Name != "Error" && !utf8Name.IsEmpty()) { hError.As<v8::Object>()->Set( v8::String::NewFromUtf8(pIsolate, "name"), v8::String::NewFromUtf8(pIsolate, utf8Name.GetCStr(), v8::String::kNormalString, utf8Name.GetLength())); } } pIsolate->ThrowException(hError); }
FX_BOOL FX_File_Exist(const CFX_ByteStringC& fileName) { FX_DWORD dwAttri = ::GetFileAttributesA(fileName.GetCStr()); if (dwAttri == -1) { return FALSE; } return (dwAttri & FILE_ATTRIBUTE_DIRECTORY) == 0; }
FX_BOOL CFXCRT_FileAccess_Posix::Open(const CFX_ByteStringC& fileName, FX_DWORD dwMode) { if (m_nFD > -1) { return FALSE; } int32_t nFlags, nMasks; FXCRT_Posix_GetFileMode(dwMode, nFlags, nMasks); m_nFD = open(fileName.GetCStr(), nFlags, nMasks); return m_nFD > -1; }
FX_BOOL CFXJSE_Value::DeleteObjectProperty(const CFX_ByteStringC& szPropName) { CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); v8::Local<v8::Value> hObject = v8::Local<v8::Value>::New(m_pIsolate, m_hValue); if (!hObject->IsObject()) { return FALSE; } hObject.As<v8::Object>()->Delete(v8::String::NewFromUtf8( m_pIsolate, szPropName.GetCStr(), v8::String::kNormalString, szPropName.GetLength())); return TRUE; }
void FX_XML_SplitQualifiedName(const CFX_ByteStringC& bsFullName, CFX_ByteStringC& bsSpace, CFX_ByteStringC& bsName) { if (bsFullName.IsEmpty()) { return; } int32_t iStart = 0; for (; iStart < bsFullName.GetLength(); iStart++) { if (bsFullName.GetAt(iStart) == ':') { break; } } if (iStart >= bsFullName.GetLength()) { bsName = bsFullName; } else { bsSpace = CFX_ByteStringC(bsFullName.GetCStr(), iStart); iStart++; bsName = CFX_ByteStringC(bsFullName.GetCStr() + iStart, bsFullName.GetLength() - iStart); } }
FX_BOOL CFXCRT_FileAccess_Win64::Open(const CFX_ByteStringC& fileName, FX_DWORD dwMode) { if (m_hFile) { return FALSE; } FX_DWORD dwAccess, dwShare, dwCreation; FXCRT_Windows_GetFileMode(dwMode, dwAccess, dwShare, dwCreation); m_hFile = ::CreateFileA(fileName.GetCStr(), dwAccess, dwShare, NULL, dwCreation, FILE_ATTRIBUTE_NORMAL, NULL); if (m_hFile == INVALID_HANDLE_VALUE) { m_hFile = NULL; } return m_hFile != NULL; }
FX_BOOL CFXJSE_Value::HasObjectOwnProperty(const CFX_ByteStringC& szPropName, FX_BOOL bUseTypeGetter) { CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); v8::Local<v8::Value> hObject = v8::Local<v8::Value>::New(m_pIsolate, m_hValue); if (!hObject->IsObject()) { return FALSE; } v8::Local<v8::String> hKey = v8::String::NewFromUtf8( m_pIsolate, szPropName.GetCStr(), v8::String::kNormalString, szPropName.GetLength()); return hObject.As<v8::Object>()->HasRealNamedProperty(hKey) || (bUseTypeGetter && hObject.As<v8::Object>()->HasOwnProperty(hKey)); }
FX_BOOL CFXJSE_Value::SetObjectOwnProperty(const CFX_ByteStringC& szPropName, CFXJSE_Value* lpPropValue) { CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); v8::Local<v8::Value> hObject = v8::Local<v8::Value>::New(m_pIsolate, m_hValue); if (!hObject->IsObject()) { return FALSE; } v8::Local<v8::Value> hValue = v8::Local<v8::Value>::New(m_pIsolate, lpPropValue->m_hValue); return hObject.As<v8::Object>()->ForceSet( v8::String::NewFromUtf8(m_pIsolate, szPropName.GetCStr(), v8::String::kNormalString, szPropName.GetLength()), hValue); }
CFX_ByteString PDF_NameDecode(const CFX_ByteStringC& bstr) { int size = bstr.GetLength(); const FX_CHAR* pSrc = bstr.GetCStr(); if (FXSYS_memchr(pSrc, '#', size) == NULL) { return bstr; } CFX_ByteString result; FX_CHAR* pDestStart = result.GetBuffer(size); FX_CHAR* pDest = pDestStart; for (int i = 0; i < size; i++) { if (pSrc[i] == '#' && i < size - 2) { *pDest++ = _hex2dec(pSrc[i + 1]) * 16 + _hex2dec(pSrc[i + 2]); i += 2; } else { *pDest++ = pSrc[i]; } } result.ReleaseBuffer((FX_STRSIZE)(pDest - pDestStart)); return result; }
FX_BOOL FX_File_Move(const CFX_ByteStringC& fileNameSrc, const CFX_ByteStringC& fileNameDst) { return ::MoveFileA(fileNameSrc.GetCStr(), fileNameDst.GetCStr()); }
FX_BOOL FX_File_Copy(const CFX_ByteStringC& fileNameSrc, const CFX_ByteStringC& fileNameDst) { return ::CopyFileA(fileNameSrc.GetCStr(), fileNameDst.GetCStr(), FALSE); }
FX_BOOL FX_File_Delete(const CFX_ByteStringC& fileName) { return ::DeleteFileA(fileName.GetCStr()); }
FX_DOUBLE XFA_ByteStringToDouble(const CFX_ByteStringC& szStringVal) { CFX_WideString wsValue = CFX_WideString::FromUTF8(szStringVal.GetCStr(), szStringVal.GetLength()); return XFA_WideStringToDouble(wsValue); }