NFile MemoryFile::create(void* memory, long len, const FilePath& fileName, bool d) { MemoryFile* mf = new MemoryFile(); mf->Buffer = memory; mf->Len = len; mf->Pos = 0; mf->Filename = fileName; mf->deleteMemoryWhenDropped = d; FSEntityPtr ret( mf ); ret->drop(); return NFile( ret ); }
NFile MemoryFile::create( ByteArray data, const FilePath& fileName ) { MemoryFile* mf = new MemoryFile(); mf->Buffer = new char[ data.size() ]; memcpy( mf->Buffer, data.data(), data.size() ); mf->Len = data.size(); mf->Pos = 0; mf->Filename = fileName; mf->deleteMemoryWhenDropped = true; FSEntityPtr ret( mf ); ret->drop(); return NFile( ret ); }
//============================================================================ // NFileUtilities::GetCWD : Get the current working directory. //---------------------------------------------------------------------------- NFile NFileUtilities::GetCWD(void) { char *thePath; NFile theFile; // Get the directory thePath = NTargetPOSIX::getcwd(NULL, 0); if (thePath != NULL) { theFile = NFile(NString(thePath, kNStringLength)); free(thePath); } return(theFile); }
//============================================================================ // NCommandLine::GetFlagFile : Get a file flag value. //---------------------------------------------------------------------------- NFile NCommandLine::GetFlagFile(const NString &theArgument) const { NFile theResult; NString theValue; // Get the value // // Relative paths are relative to the current working directory. theValue = GetFlagString(theArgument); if (!theValue.IsEmpty()) { if (!theValue.StartsWith("/")) theValue = NFileUtilities::GetCWD().GetPath() + "/" + theValue; theResult = NFile(theValue); } return(theResult); }