//---------------------------------------------------------------------------------------- nsresult nsFileSpec::MoveToDir(const nsFileSpec& inNewParentDirectory) //---------------------------------------------------------------------------------------- { // We can only copy into a directory, and (for now) can not copy entire directories nsresult result = NS_FILE_FAILURE; if (inNewParentDirectory.IsDirectory() && !IsDirectory()) { char *leafname = GetLeafName(); nsSimpleCharString destPath(inNewParentDirectory.GetCString()); destPath += "/"; destPath += leafname; nsCRT::free(leafname); result = NS_FILE_RESULT(CrudeFileCopy(GetCString(), (const char*)destPath)); if (result == NS_OK) { // cast to fix const-ness ((nsFileSpec*)this)->Delete(PR_FALSE); *this = inNewParentDirectory + GetLeafName(); } } return result; }
Variant JSONValue::GetVariantValue(unsigned index, VariantType type) const { Variant ret; if (type == VAR_RESOURCEREF) ret = GetResourceRef(index); else if (type == VAR_RESOURCEREFLIST) ret = GetResourceRefList(index); else if (type == VAR_VARIANTVECTOR || type == VAR_VARIANTMAP) LOGERROR("Unsupported value type"); else ret.FromString(type, GetCString(index)); return ret; }
//---------------------------------------------------------------------------------------- nsresult nsFileSpec::CopyToDir(const nsFileSpec& inParentDirectory) const //---------------------------------------------------------------------------------------- { // We can only copy into a directory, and (for now) can not copy entire directories nsresult result = NS_FILE_FAILURE; if (inParentDirectory.IsDirectory() && (! IsDirectory() ) ) { char *leafname = GetLeafName(); nsSimpleCharString destPath(inParentDirectory.GetCString()); destPath += "/"; destPath += leafname; nsCRT::free(leafname); result = NS_FILE_RESULT(CrudeFileCopy(GetCString(), destPath)); } return result; } // nsFileSpec::CopyToDir
//---------------------------------------------------------------------------------------- nsresult nsFileSpec::CopyToDir(const nsFileSpec& inParentDirectory) const //---------------------------------------------------------------------------------------- { // We can only copy into a directory, and (for now) can not copy entire directories if (inParentDirectory.IsDirectory() && (! IsDirectory() ) ) { char *leafname = GetLeafName(); nsSimpleCharString destPath(inParentDirectory.GetCString()); destPath += "\\"; destPath += leafname; nsCRT::free(leafname); // CopyFile returns non-zero if succeeds int copyOK = CopyFile(GetCString(), destPath, PR_TRUE); if (copyOK) return NS_OK; } return NS_FILE_FAILURE; } // nsFileSpec::CopyToDir
Variant JSONValue::GetVectorVariant(unsigned index) const { return ToVectorVariant(GetCString(index)); }
Matrix4 JSONValue::GetMatrix4(unsigned index) const { return ToMatrix4(GetCString(index)); }
Quaternion JSONValue::GetQuaternion(const String& name) const { return ToQuaternion(GetCString(name)); }
IntRect JSONValue::GetIntRect(unsigned index) const { return ToIntRect(GetCString(index)); }
IntVector2 JSONValue::GetIntVector2(unsigned index) const { return ToIntVector2(GetCString(index)); }
Color JSONValue::GetColor(unsigned index) const { return ToColor(GetCString(index)); }
PODVector<unsigned char> JSONValue::GetBuffer(unsigned index) const { PODVector<unsigned char> buffer; StringToBuffer(buffer, GetCString(index)); return buffer; }
Color JSONValue::GetColor(const String& name) const { return ToColor(GetCString(name)); }
Variant JSONValue::GetVectorVariant(const String& name) const { return ToVectorVariant(GetCString(name)); }
Vector4 JSONValue::GetVector4(unsigned index) const { return ToVector4(GetCString(index)); }
Matrix4 JSONValue::GetMatrix4(const String& name) const { return ToMatrix4(GetCString(name)); }
IntVector2 JSONValue::GetIntVector2(const String& name) const { return ToIntVector2(GetCString(name)); }
IntRect JSONValue::GetIntRect(const String& name) const { return ToIntRect(GetCString(name)); }
PODVector<unsigned char> JSONValue::GetBuffer(const String& name) const { PODVector<unsigned char> buffer; StringToBuffer(buffer, GetCString(name)); return buffer; }
Quaternion JSONValue::GetQuaternion(unsigned index) const { return ToQuaternion(GetCString(index)); }
Vector4 JSONValue::GetVector4(const String& name) const { return ToVector4(GetCString(name)); }