Пример #1
0
//----------------------------------------------------------------------------------------
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;
} 
Пример #2
0
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;
}
Пример #3
0
//----------------------------------------------------------------------------------------
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
Пример #4
0
//----------------------------------------------------------------------------------------
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
Пример #5
0
Variant JSONValue::GetVectorVariant(unsigned index) const
{
    return ToVectorVariant(GetCString(index));
}
Пример #6
0
Matrix4 JSONValue::GetMatrix4(unsigned index) const
{
    return ToMatrix4(GetCString(index));
}
Пример #7
0
Quaternion JSONValue::GetQuaternion(const String& name) const
{
    return ToQuaternion(GetCString(name));
}
Пример #8
0
IntRect JSONValue::GetIntRect(unsigned index) const
{
    return ToIntRect(GetCString(index));
}
Пример #9
0
IntVector2 JSONValue::GetIntVector2(unsigned index) const
{
    return ToIntVector2(GetCString(index));
}
Пример #10
0
Color JSONValue::GetColor(unsigned index) const
{
    return ToColor(GetCString(index));
}
Пример #11
0
PODVector<unsigned char> JSONValue::GetBuffer(unsigned index) const
{
    PODVector<unsigned char> buffer;
    StringToBuffer(buffer, GetCString(index));
    return buffer;
}
Пример #12
0
Color JSONValue::GetColor(const String& name) const
{
    return ToColor(GetCString(name));
}
Пример #13
0
Variant JSONValue::GetVectorVariant(const String& name) const
{
    return ToVectorVariant(GetCString(name));
}
Пример #14
0
Vector4 JSONValue::GetVector4(unsigned index) const
{
    return ToVector4(GetCString(index));
}
Пример #15
0
Matrix4 JSONValue::GetMatrix4(const String& name) const
{
    return ToMatrix4(GetCString(name));
}
Пример #16
0
IntVector2 JSONValue::GetIntVector2(const String& name) const
{
    return ToIntVector2(GetCString(name));
}
Пример #17
0
IntRect JSONValue::GetIntRect(const String& name) const
{
    return ToIntRect(GetCString(name));
}
Пример #18
0
PODVector<unsigned char> JSONValue::GetBuffer(const String& name) const
{
    PODVector<unsigned char> buffer;
    StringToBuffer(buffer, GetCString(name));
    return buffer;
}
Пример #19
0
Quaternion JSONValue::GetQuaternion(unsigned index) const
{
    return ToQuaternion(GetCString(index));
}
Пример #20
0
Vector4 JSONValue::GetVector4(const String& name) const
{
    return ToVector4(GetCString(name));
}