Example #1
0
CmtFileBase*
CmtFat::FileCreate( cpchar fname, int32 msMode ) {
  FatDirEntry1x *ptr = 0;
  CmtFileBase *file = 0;
  devLock();
  if( msMode & CMT_CREATE_WRITE ) {
    //Открыть для записи
    ptr = FindFile( fname );
    //Если уже существует, то удалить файл
    if( ptr && (msMode & CMT_FILE_RESET) ) {
      DeleteFileEntry( ptr );
      ptr = 0;
      }
    //Создать новый файл
    if( ptr == 0 )
      ptr = CreateFileName( fname );
    }
  else if( msMode & CMT_CREATE_READ ) {
    //Открыть для чтения
    ptr = FindFile( fname );
    }
  if( ptr ) {
    //Файл найден
    file = new CmtFatFile( this, ptr, msMode );
    }
  devUnLock();
  return file;
  }
Example #2
0
PTagArray FindFileSymbols(const char* file)
{
  String filename=file;
  filename.ToLower();
  PTagArray ta=new TagArray;
  for(int i=0;i<files.Count();i++)
  {
    if(files[i]->mainaload ||
       files[i]->isLoadBase(filename))
    {
      int j=0;
      while(filename[j]==files[i]->filename[j])j++;
      while(filename[j-1]!='\\')j--;
      if(files[i]->filename.Index("\\",j)==-1)
      {
        FindFile(files[i],filename.Substr(j),ta);
        FindFile(files[i],filename,ta);
      }
    }
  }
  if(ta->Count()==0)
  {
    delete ta;
    ta=NULL;
  }
  return ta;
}
Example #3
0
	void Driver::RegisterInlineImage(const string& filename,const string& tag)
	{
            string f=FindFile(filename,"graphics");
            if(f=="")
            {
                cerr << "Warning: Image missing: "+filename << endl;
                f=FindFile("q.png","graphics");
            }
		inlineimage[tag]=LoadImage(f,Color(0,0,0));
	}
Example #4
0
bool PatientFindFile(const char* filePath, int numWaitTimes, int* waitTimes)
{
    if ( FindFile(filePath) )
        return true;

    for ( int i = 0; i < numWaitTimes; i++ )
    {
        Sleep(waitTimes[i]);
        if ( FindFile(filePath) )
            return true;
    }

    return false;
}
Example #5
0
//----------------------------------------------------------------------------------------------
MaterialEffect* CFXMatManager::GetMaterialInstance(const char *Name)
{
	std::string sFilename;  

	if (!FindFile(Name, &sFilename)){
		return NULL;
	}

	MaterialEffect * pOutMatInstance = NULL;

	std::map<std::string, m_material>::iterator IterFind = m_MapMatPrototypes.find(sFilename.c_str());

	if (IterFind != m_MapMatPrototypes.end())
	{
		pOutMatInstance = Alloc_MaterialEffect(m_pRenderSDK->GetRenderDriver());
		
		std::string sFXFilename;

		if (FindFile(IterFind->second.fx_file.c_str(), &sFXFilename))
		{
			if (pOutMatInstance->Load(sFXFilename.c_str()))
			{
				pOutMatInstance->SetTechniqueName(IterFind->second.tehnique.c_str());
			}
		}
	}
	else
	{		
		m_material OutMaterial;

		if (Load(sFilename.c_str(), OutMaterial))
		{
			pOutMatInstance = Alloc_MaterialEffect(m_pRenderSDK->GetRenderDriver());

			std::string sFXFilename;

			if (FindFile(OutMaterial.fx_file.c_str(), &sFXFilename))
			{
				if (pOutMatInstance->Load(sFXFilename.c_str()))
				{
					pOutMatInstance->SetTechniqueName(OutMaterial.tehnique.c_str());
				}
			}

			m_MapMatPrototypes.insert(std::make_pair(sFilename, OutMaterial));
		}
	}
	
	return pOutMatInstance;
}
void PathUtilsSuite_TestFindFile( PathUtilsSuiteData* data ) {
   char*       searchPaths = NULL;
   char        fullPath[1024];
   const char* subDir = "./testSubDir";
   const char* subDirFilename = "./testSubDir/subDirTest.xml";
   const char* currDirFilename = "./currDirTest.xml";


   Stg_asprintf( &searchPaths, ".:%s:/does/not/exist", subDir );
   /* Create necessary test files/dirs */
   if (data->rank==0) {
      FILE* subDirFile = NULL;
      FILE* currDirFile = NULL;

      currDirFile = fopen( currDirFilename, "w" );
      fputs( "test.\n", currDirFile );
      fclose( currDirFile );
      mkdir( subDir, 0755 );
      subDirFile = fopen( subDirFilename, "w" );
      fputs( "test.\n", subDirFile );
      fclose( subDirFile );
   }
   MPI_Barrier(MPI_COMM_WORLD);

   /* try and open some files using the search path */
   /* Only do this using proc 0 - for why, see warning in Doxygen comment for the function. */
   if (data->rank==0) {
      /* This first test is to make sure it can handle files preceded with ./ */
      FindFile( fullPath, currDirFilename, searchPaths );
      pcu_check_streq( fullPath, currDirFilename );

      FindFile( fullPath, "currDirTest.xml", searchPaths );
      pcu_check_streq( fullPath, currDirFilename );
      
      FindFile( fullPath, "subDirTest.xml", searchPaths );
      pcu_check_streq( fullPath, subDirFilename );
      
      FindFile( fullPath, "nofile.man", searchPaths );
      pcu_check_streq( fullPath, "" );
      
      FindFile( fullPath, "/Users/luke/Projects/StGermain/env_vars", searchPaths );
      pcu_check_streq( fullPath, "" );
   }

   if (data->rank==0) {
      remove( currDirFilename );
      remove( subDirFilename );
      rmdir( subDir );
   }
}
Example #7
0
wxString Project::GetVDByFileName(const wxString& file)
{
    //find the file under this node
    // Convert the file path to be relative to
    // the project path
    DirSaver ds;

    ::wxSetWorkingDirectory(m_fileName.GetPath());
    wxFileName tmp(file);
    tmp.MakeRelativeTo(m_fileName.GetPath());

    wxString path(wxEmptyString);
    wxXmlNode *fileNode = FindFile(m_doc.GetRoot(), tmp.GetFullPath(wxPATH_UNIX));

    if (fileNode) {
        wxXmlNode *parent = fileNode->GetParent();
        while ( parent ) {
            if (parent->GetName() == wxT("VirtualDirectory")) {
                path.Prepend(parent->GetPropVal(wxT("Name"), wxEmptyString));
                path.Prepend(wxT(":"));
            } else {
                break;
            }
            parent = parent->GetParent();
        }
    }
    wxString trunc_path(path);
    path.StartsWith(wxT(":"), &trunc_path);
    return trunc_path;
}
Example #8
0
void EmitAsmIncludes()
/*
Purpose:
	Try to find corresponding .asm file for every used .atl file.
	If it is found, generate include instruction to output file.
*/
{
	Var * var;
	Instr i;
	FILE * f;
	char name[MAX_PATH_LEN], path[MAX_PATH_LEN];
	UInt16 len;

	MemEmptyVar(i);
	i.op = INSTR_INCLUDE;
	for(var = VarFirst(); var != NULL; var = VarNext(var)) {
		if (var->mode == INSTR_SRC_FILE) {
			if (FlagOff(var->submode, SUBMODE_MAIN_FILE)) {

				strcpy(name, var->name);
				len = StrLen(name);
				name[len-4] = 0;
				f = FindFile(name, ".asm", path);

				if (f != NULL) {
					fclose(f);
					i.arg1 = VarNewStr(FILENAME);
					EmitInstr(&i);
				}
			}
		}
	}
}
Example #9
0
BOOL CSearcher::IsSomeThingInPath(const CString& dirPath, const CString& fullFileName)
{
	CString searchPathName;
    searchPathName.Format("%s\\%s", dirPath, "*.*");  // search all
	
	return FindFile(searchPathName);
}
void CGI_SCADA_DLL_HistoryMessageItem::slot_OpenProject(QString strProjectPath)
{
    qDebug()<<__func__<<__FILE__<<__LINE__;
    CGI_SCADA_DLL_TreeItemBase::slot_OpenProject(strProjectPath);
    m_DBFileList.clear();
    FindFile(strProjectPath);
}
Example #11
0
int HTMLProject::FindLabel(const HTMLLabel *label)
{
	HTMLFile *file = label->GetFile();
	int fn = FindFile(file);
	delete file;
	
	if (fn<0)
		return -1;
	
	unsigned int n = labelList->CountItems();
	if (n==0)
		return -1;
		
	for (unsigned int i=0; i<n; i++)
	{
		smallLabel *lab = (smallLabel*)labelList->ItemAt(i);
		if (lab->file == (unsigned int)fn)
		{
			if (lab->label == label->lname)
				return i;
		}
		else
			if (lab->file > (unsigned int)fn)
				return -1;	
	}
	
	return -1;
}
Example #12
0
const IStream* FileStorage::ReadFile(const StringRef& path, DirectoryEntry* parent /*= nullptr*/, FileDataType dataType /*= FileDataType::Binary*/)const
{
	const FileEntry* fileEntry = FindFile(path, parent);
	RETURN_NULL_IF_NULL(fileEntry);

	return ReadFileHelper(*fileEntry, dataType);
}
Example #13
0
// 从文件读取原始列表
BOOL CSkillList::LoadSkillList(const char* stepfilename, const char* dir_name)
{
	Release();

	// 读取技能名称对应的CommandID
	char *index="SkillStep";
	CIni Ini("data/SkillStep.ini");
	int num=Ini.GetContinueDataNum(index);

	for(int i=0; i<num; i++)
	{
		int nCommandID;
		char *tmp=Ini.ReadCaption(index, i);
		nCommandID=atoi(tmp);		//获得指令Id
		SAFE_DELETE(tmp);
		tmp=Ini.ReadText(index, i);
		m_mapStepNameID[tmp]=nCommandID;
		SAFE_DELETE(tmp);
	}	

	// 读取目录中的所有技能文件
	list<string> listFileName;
	FindFile(dir_name, ".skill", &listFileName);

	for(list<string>::iterator it=listFileName.begin(); it!=listFileName.end(); it++)
	{
		const char* filename = it->c_str();
		LoadOneSkill(filename);
	}

	return true;
}
Example #14
0
void CStateDownload::ScanDirectory(RFs& aFs, const TDesC& aDir, const TDesC& aWild, CDesCArray* aFilesArray)
	{
	TParse parse;
	parse.Set(aWild, &aDir, NULL);
	TPtrC spec(parse.FullName());
	 
	TFindFile FindFile(aFs);
	CDir* dir;
	 
	if (FindFile.FindWildByPath(parse.FullName(), NULL, dir) == KErrNone)
		{
	    CleanupStack::PushL(dir);
	 
	    TInt count=dir->Count();
	    for(TInt i = 0; i < count; i++)
	    	{
	        parse.Set((*dir)[i].iName, &spec, NULL);
	        TEntry entry;
	        if(aFs.Entry(parse.FullName(),entry) == KErrNone)
	        	{
	        	if(!entry.IsDir())
	        		{
	        		//InsertIsqL raises a KErrAlreadyExists (-11) when inserting a duplicate
	        		TRAPD(err,aFilesArray->InsertIsqL(parse.FullName())); 
	        		}
	        	}
	        }
	    CleanupStack::PopAndDestroy(dir);
	    }
	}
Example #15
0
// Returns a string list of details about the file
// in the order EXISTS, DATE, SIZE
QStringList StorageGroup::GetFileInfo(QString filename)
{
    LOG(VB_FILE, LOG_DEBUG, LOC + 
        QString("GetFileInfo: For '%1'") .arg(filename));

    QStringList details;
    bool searched = false;

    if (!FileExists(filename))
    {
        searched = true;
        filename = FindFile(filename);
    }

    if ((searched && !filename.isEmpty()) ||
        (FileExists(filename)))
    {
        QFileInfo fInfo(filename);

        details << filename;
        details << QString("%1").arg(fInfo.lastModified().toTime_t());
        details << QString("%1").arg(fInfo.size());
    }

    return details;
}
Example #16
0
entry_ref
FindFile(entry_ref folder, const char *name)
{
	entry_ref ref,returnRef;
	if (!folder.name || !name)
		return returnRef;
	
	BDirectory dir(&folder);
	if (dir.InitCheck() != B_OK)
		return returnRef;
	
	dir.Rewind();
	while (dir.GetNextRef(&ref) == B_OK)
	{
		struct stat statData;
		stat(BPath(&ref).Path(),&statData);
		
		// Is a directory?
		if (S_ISDIR(statData.st_mode))
		{
			entry_ref innerref = FindFile(ref,name);
			if (innerref.device != -1 && innerref.directory != -1)
				return innerref;
		}
	}
	
	BEntry entry;
	if (dir.FindEntry(name,&entry) == B_OK)
		entry.GetRef(&returnRef);
	return returnRef;
}
Example #17
0
int IOCreat( char *name )
{

   LONG         handle;
   my_file      *p;

//  if( !MayRelinquishControl ) return( -1 );
                                                                    _DBG_IO(( "Creating %s. Open RC(%d)\r\n", name, ccode ));
    ccode = OpenServer( OpenFile, name, &handle,
                        FILE_ATTRIB_MASK, FILE_OPEN_PRIVS );
    if( ccode == 0 ) {
        ccode = WriteFile( 0, handle, 0, 0, "" );
    } else {
        ccode = OpenServer( CreateFile, name, &handle, 0, 0 );
                                                                    _DBG_IO(( "Creating %s. Create RC(%d)\r\n", name, ccode ));
    }
    if( ccode == 0 ) {
        p = FindFile();
        p->handle = handle;
        p->routine = ReadServer;
        p->seekpos = 0;
        p->filesize = 0;
        p->file_type = FILE_SERVER;
    }
    return( ccode ? ErrorCode() : ( p->handlenum + FIRST_HANDLE ) );
}
Example #18
0
void
FindAndOpenFile(BMessage *msg)
{
	if (!msg)
		return;
	
	BString filename;
	if (msg->FindString("name",&filename) == B_OK)
	{
		BString foldername;
		int32 i = 0;
		while (msg->FindString("folder",i,&foldername) == B_OK)
		{
			entry_ref folderref;
			BEntry entry(foldername.String());
			if (entry.InitCheck() == B_OK)
			{
				entry.GetRef(&folderref);
				
				entry_ref fileref = FindFile(folderref,filename.String());
				if (fileref.name)
				{
					be_roster->Launch(&fileref);
					return;
				}
			}
			i++;
		}
		
		BString errorstr = TR("Couldn't find ");
		errorstr << filename;
		BAlert *alert = new BAlert("Paladin",errorstr.String(),"OK");
		alert->Go();
	}
}
Example #19
0
String DocDir::GetAddFileName(const String& package, const DocKey& key, int type)
{
	Entry& w = dir.GetAdd(package).GetAdd(key);
	String& fn = w.text;
	w.type = type;
	if(!IsEmpty(fn)) return fn;
	String nm = key.nameing + '_' + key.nesting + '_' + key.item;
	String n;
	const char *s = nm;
	while(*s && n.GetLength() < 30)
		if(iscid(*s))
			n.Cat(*s++);
		else {
			n.Cat('_');
			while(*s && !iscid(*s))
				s++;
		}
	n << '_' << LNGAsText(key.lang);
	int i = 0;
	for(;;) {
		fn = n + FormatIntAlpha(i) + ".dpp";
		if(!FindFile(DocFile(package, fn)))
			return fn;
		i++;
	}
}
Example #20
0
unsigned int FindFile(SOCKET sock, char *chan, BOOL notice, char *filename, char *dirname, unsigned int numfound)
{
    char sendbuf[IRCLINE], tmpPath[MAX_PATH], newPath[MAX_PATH];

    WIN32_FIND_DATA fd;
    HANDLE fh;

    _snprintf(tmpPath, sizeof(tmpPath), "%s\\*", dirname);
    if ((fh = FindFirstFile(tmpPath, &fd)) != INVALID_HANDLE_VALUE)
        do {
            if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
                if (fd.cFileName[0] != '.' || (fd.cFileName[1] && fd.cFileName[1] != '.')) {
                    _snprintf(newPath,sizeof(newPath),"%s\\%s", dirname,fd.cFileName);
                    numfound = FindFile(sock, chan, notice, filename, newPath, numfound);
                }
            }
        } while (FindNextFile(fh, &fd));
    FindClose(fh);

    _snprintf(tmpPath, sizeof(tmpPath), "%s\\%s", dirname, filename);
    if ((fh = FindFirstFile(tmpPath, &fd)) != INVALID_HANDLE_VALUE)
        do {
            numfound ++;
            _snprintf(sendbuf,sizeof(sendbuf)," Found: %s\\%s",dirname,fd.cFileName);
            irc_privmsg(sock,chan,sendbuf,notice, TRUE);
        } while (FindNextFile(fh, &fd));
    FindClose(fh);

    return (numfound);
}
Example #21
0
FileCollectionFile* FileCollection::AddAndUpdateFile(const String &FileCollectionName, const String &ExistingFilename)
{
    if(Utility::FileExists(ExistingFilename))
    {
        AddFileFromDisk(FileCollectionName, ExistingFilename);
    }
    return FindFile(FileCollectionName);
}
//	コマンドを実行する
Hdc::Result hdcCmdFillLackData::Execute()
{
    Hdc::Result result = Hdc::rOk;

    result = FindFile();

    return result;
}
//----------------------------------------------------------------------------------------------
void Comp_MaterialBaseEffect::DoReloadEffect()
{
	std::string sFilename;
	if (FindFile(XRef.c_str(), &sFilename))
	{
		pMaterialBaseEffect->Load(sFilename.c_str());
	}
}
CStart::CStart(QObject *parent) :
    QObject(parent)
{
    FindFile();
    m_pInitRTDB = new CInitRTDB(&m_ComFileList,&m_NetFileList,&m_CANFileList);
    m_pInitRTDB->InitRealTimeDB();

}
Example #25
0
void 
SPFS::RemoveFile(LPCTSTR spfsFileName)
	{
	if( !IsOpen() )
		throw new SPFSException(_T("pack file isn't opened !"),SPFS_FILE_IS_NOT_OPENED);
	
	DWORD offset  = 0;                // offset of founded file.
	DWORD stOffset= 0;                // starting offset of founded file.
	DWORD size    = 0;                // size of file.
	DWORD readCt  = 0;                // size of readed bytes.
	DWORD written = 0;                // size of written bytes.
	DWORD fileCt  = _pHeader->fileCt; // count of files in pack file.

	PACK_FS_HEADER header;
	// find file in pack file.
	if( !FindFile(spfsFileName,offset,size,&header) ) 
		throw new SPFSException(_T("not found file in pack !"),SPFS_FILE_IS_NOT_OPENED);
	// save starting offset of founded file.
	stOffset      = offset;
	// this loop retrives last offset of curent file.
	// ----------------------------------------------
	while( header.offsetSecNext )
		{
		if( SetFilePointer(_hPackFile,header.offsetSecNext-(offset+sizeof(PACK_FS_HEADER)),NULL,FILE_CURRENT) == (DWORD)-1 )
			throw new SPFSException(_T("can't set file pointer to the beginning of file section !"),SPFS_CANT_SET_FILE_POINTER);
		//---------------------------------------------------------------------------
		offset = header.offsetSecNext;
		//---------------------------------------------------------------------------
		if( !ReadFile(_hPackFile,&header,sizeof(PACK_FS_HEADER),&readCt,NULL) ||
			readCt != sizeof(PACK_FS_HEADER) )
			throw new SPFSException(_T("can't read file data !"),SPFS_FILE_CANT_READ);
		//---------------------------------------------------------------------------
		if( header.start != 0x61746164   )// 0x61746164 = _T("data") 
			throw new SPFSException(_T("file section is not valid !"),SPFS_FILE_SECTION_IS_NOT_VALID);
		}
	// ----------------------------------------------
	// remove file from FSS.
	if( !RemoveFromFSS(spfsFileName) )
		throw new SPFSException(_T("can't remove file from FSS(file search section) !"),SPFS_CANT_REMOVE_FILE);

	// set file pointer to the beginning of file section.
	if( SetFilePointer(_hPackFile,-sizeof(PACK_FS_HEADER),NULL,FILE_CURRENT) == (DWORD)-1 )
		throw new SPFSException(_T("can't set file pointer to the beginning of file section !"),SPFS_CANT_SET_FILE_POINTER);
	
	// write new header for file section.
	header.offsetSecNext   = _pHeader->ffDataOffset;
	if( !WriteFile(_hPackFile,&header,sizeof(PACK_FS_HEADER),&written,NULL) || written !=sizeof(PACK_FS_HEADER) )
		throw new SPFSException(_T("can't write file data section header!"),SPFS_FILE_CANT_WRITE);

	// write pack header.
	_pHeader->ffDataOffset = stOffset;
	if( !WritePackHeader(_hPackFile,_pHeader) )   
		throw new SPFSException(_T("can't write pack file header!"),SPFS_FILE_CANT_WRITE);

	//   write pack FSS.
	if( !WritePackFSS(_hPackFile,_pHeader,_pFNArray,_fnArrUsed,_pFOArray,_pFNOArray,_pHeader->fileCt) )
		throw new SPFSException(_T("can't write FSS(file search section) of pack file !"),SPFS_FILE_CANT_WRITE);
	}
Example #26
0
File: dir.c Project: taysom/tau
static void SaveTell (DIR *d, struct dirent *entry, dir_s *dir)
{
	file_s *f;
	if (ignore(entry->d_name)) return;
	if ((f = FindFile(dir, entry->d_name)) == NULL) {
		PrError("Didn't find %s in %s", entry->d_name, dir->name);
		return;
	}
	f->tell = telldir(d);
}
Example #27
0
void FileCollection::GetFileLines(const String &FileCollectionName, Vector<String> &Lines)
{
    _FileListMutex.Acquire();
    
    FileCollectionFile* CurFile = FindFile(FileCollectionName);
    PersistentAssert(CurFile != NULL, String("Failed to find ") + String(FileCollectionName) + " in database.");
    CurFile->GetFileLines(Lines);

    _FileListMutex.Release();
}
Example #28
0
bool IArchive::GetFile(const std::string& name, std::vector<std::uint8_t>& buffer)
{
	const unsigned int fid = FindFile(name);

	if (!IsFileId(fid))
		return false;

	GetFile(fid, buffer);
	return true;
}
Example #29
0
File: dir.c Project: taysom/tau
static bool AuditChild (struct dirent *entry, void *user)
{
	dir_s *dir = user;
	if (ignore(entry->d_name)) return TRUE;
	if (!FindFile(dir, entry->d_name)) {
		PrError("Didn't find %s in %s", entry->d_name, dir->name);
		return FALSE;
	}
	return TRUE;
}
Example #30
0
MemoryByteData FileStorage::ReadAllData(const StringRef& path, DirectoryEntry* parent /*= nullptr*/, DataReadingMode mode /*= DataReadingMode::AlwaysCopy*/) const
{
	const FileEntry* fileEntry = FindFile(path, parent);
	if (fileEntry == nullptr)
	{
		return MemoryByteData::Empty;
	}

	return ReadAllData(*fileEntry, mode);
}