Exemplo n.º 1
0
static long
FileLoadMKext( const char * dirSpec, const char * extDirSpec )
{
  long      ret, flags;
  u_int32_t time, time2;
	char	altDirSpec[512];
	
	snprintf(altDirSpec, sizeof(altDirSpec), "%s%s", dirSpec, extDirSpec);
	ret = GetFileInfo(altDirSpec, "Extensions.mkext", &flags, &time);

	if ((ret == 0) && ((flags & kFileTypeMask) == kFileTypeFlat))
	{
		ret = GetFileInfo(dirSpec, "Extensions", &flags, &time2);

		if ((ret != 0)
			|| ((flags & kFileTypeMask) != kFileTypeDirectory)
			|| (((gBootMode & kBootModeSafe) == 0) && (time == (time2 + 1))))
		{
			snprintf(gDriverSpec, sizeof(altDirSpec) + 18, "%sExtensions.mkext", altDirSpec);
			verbose("LoadDrivers: Loading from [%s]\n", gDriverSpec);

			if (LoadDriverMKext(gDriverSpec) == 0) {
				return 0;
			}
		}
	}
	return -1;
}
Exemplo n.º 2
0
void CSpyUserPanel::OnSpyFileItemActivated(wxListEvent& event)
{
    wxString strCurLocaitoin = m_pFileLocationText->GetValue();
    bool bIsRootLocation = strCurLocaitoin.Length() == 3 && strCurLocaitoin[1] == _T(':');
    wxString strItem = event.GetItem().GetText();
    wxString strNewLocation = strItem;
    if (strCurLocaitoin != _T("我的电脑"))
    {
        if (*strCurLocaitoin.rbegin() != _T('/'))
        {
            strCurLocaitoin.append(_T("/"));
        }
        strNewLocation = strCurLocaitoin.append(strItem);
    }
    TCHAR szPath[MAX_PATH];
    if (strItem == _T("..") && bIsRootLocation)
    {
        szPath[0] = 0;
    }
    else
    {
        CFilePathTool::GetInstance()->Canonical(szPath, strNewLocation.c_str());
    }    
    GetFileInfo(szPath, false);
}
Exemplo n.º 3
0
cFileInfoMenu::cFileInfoMenu(std::string mrl) : cOsdMenu( tr("File Info:"), 12)
{
	//set title
	//SetTitle(tr("mediaplayer - Id3 Info:"));
	mrl_ = mrl;
	fileInfoVec_ = GetFileInfo(mrl_);

	// Get title
	std::string title;
	TagLib::FileRef f( mrl.c_str() );
	if(!f.isNull() && f.tag())
	{
		TagLib::Tag *tag = f.tag();
								 // unicode = false
		title   = tag->title().stripWhiteSpace().toCString(false)  ;

		if (title.size())
		{
			char buffer[128];
			snprintf(buffer, 127, "File Info: %s", title.c_str());
			SetTitle(buffer);
			printf("setting title to : %s\n", buffer);
		}
	}

	ShowInfo();
}
Exemplo n.º 4
0
///////////////////////////////////////////////////////////////////////////////
//
// Search for the target using the vPath
fileinfo* mhmakefileparser::SearchvPath(const fileinfo* pTarget)
{
  string TargetName=pTarget->GetName();
  vector< pair< string, refptr<fileinfoarray> > >::iterator vPathIt=m_vPath.begin();
  while (vPathIt!=m_vPath.end())
  {
    matchres Res;

    if (PercentMatch(TargetName,vPathIt->first,&Res))
    {
      fileinfoarray::iterator pIt=vPathIt->second->begin();
      while (pIt!=vPathIt->second->end())
      {
        fileinfo* pNewTarget=GetFileInfo(TargetName,*pIt);
        mh_time_t TargetDate=StartBuildTarget(pNewTarget,false);
        if (!TargetDate.IsDateValid())
          TargetDate=WaitBuildTarget(pNewTarget);
        if (pNewTarget->GetDate().DoesExist())
          return pNewTarget;
        pIt++;
      }
    }
    vPathIt++;
  }
  return NULL;
}
Exemplo n.º 5
0
        void UnixFileSystemBase::GetFiles(const String& path, Array<FileInfo>& list)
        {
            String prefix = 
                path.Length() > 0 && path.Last() != '/' ? 
                    path + "/" : 
                    path;

            DIR *dp;
            struct dirent *ep;

            if ((dp = opendir(prefix.Ptr())) == NULL)
                XLI_THROW_FILE_NOT_FOUND(prefix);

            if (prefix == "./")
                prefix = "";

            while ((ep = readdir(dp)) != NULL)
            {
                String fn = ep->d_name;
                
                if (fn == "." || fn == "..") 
                    continue;

                FileInfo info;
                if (GetFileInfo(prefix + fn, info))
                    list.Add(info);
            }

            closedir(dp);
        }
Exemplo n.º 6
0
	FolderInfo FileSystem::GetFolderInfo(const String& path) const
	{
		FolderInfo res;
		res.path = path;

		WIN32_FIND_DATA f;
		HANDLE h = FindFirstFile(path + "/*", &f);
		if (h != INVALID_HANDLE_VALUE)
		{
			do
			{
				if (strcmp(f.cFileName, ".") == 0 || strcmp(f.cFileName, "..") == 0)
					continue;

				if (f.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY)
					res.folders.Add(GetFolderInfo(path + "/" + f.cFileName));
				else
					res.files.Add(GetFileInfo(path + "/" + f.cFileName));
			} while (FindNextFile(h, &f));
		}
		else
			mInstance->mLog->Error("Failed GetPathInfo: Error opening directory " + path);

		FindClose(h);

		return res;
	}
Exemplo n.º 7
0
int nb_qfileinfo(int handle)
{
    int     i;
    int     rc;
    char    FileName[128];
    char    temp[512];
    DWORD   gle;

    sprintf(FileName, "Thread_%05d.log", ProcessNumber);

    if ((i = FindHandle(handle)) == -1)
        return(-1);

    StartFirstTimer();
    rc = GetFileInfo(ftable[i].name, ftable[i].fd, NULL, NULL, NULL, NULL, NULL, NULL);
    gle = GetLastError();
    if (!rc)
    {
        EndFirstTimer(CMD_QUERY_FILE_INFO, 0);
        LeaveThread(0, "", CMD_QUERY_FILE_INFO);
        sprintf(temp, "File: qfileinfo failed for %s GLE(0x%x)\n", ftable[i].name, gle);
        if (verbose)
            printf("%s", temp);
        LogMessage(ProcessNumber, HostName, FileName, temp, LogID);
        return(-1);
    }
    EndFirstTimer(CMD_QUERY_FILE_INFO, 1);

    return(0);
}
Exemplo n.º 8
0
	bool GetFileList(const string &sStoragePath, string &sOutResponse)
	{
		START_FUNCTION_BOOL();
		ASSERTE(!sStoragePath.empty());

		const sizeint siStoragePathLength = sStoragePath.length();

		string_v vsFilesList;
		sizeint siFilesCount = FileUtils::GetFileListRecursive(sStoragePath.c_str(), vsFilesList);

		string sResult;
		sizeint siEstimatedLength = (sStoragePath.length() + 1) * siFilesCount;
		sResult.reserve(siEstimatedLength);

		for (sizeint siIndex = 0; siIndex < siFilesCount; ++siIndex)
		{
			string &sCurrentFile = vsFilesList[siIndex];
			ASSERTE(sCurrentFile.length() > siStoragePathLength);

			string sFileInfo;
			if (GetFileInfo(sCurrentFile, sFileInfo))
			{
				string sCurrentFileItem = sCurrentFile.substr(siStoragePathLength) + sFileInfo;
				sResult.append(sCurrentFileItem);
			}
		}

		sOutResponse = sResult;
		END_FUNCTION_BOOL();
	}
Exemplo n.º 9
0
bool CZipArchive::ExtractFile(WORD uIndex, LPCTSTR lpszPath, DWORD nBufSize)
{
	if (!nBufSize)
		return false;
	
	CFileHeader header;
	GetFileInfo(header, uIndex); // to ensure that slash and oem conversions take place
	CString szFile = lpszPath;
	szFile.TrimRight(_T("\\"));
	szFile += _T("\\") + GetFileDirAndName(header.m_szFileName); // just in case in the archive there are file names with drives
	if (IsFileDirectory(uIndex))
	{
		ForceDirectory(szFile);
		SetFileAttributes(szFile, header.m_uExternalAttr);
	}
	else
	{
		if (!OpenFile(uIndex))
			return false;
		ForceDirectory(GetFilePath(szFile));
		CFile f(szFile, CFile::modeWrite | CFile::modeCreate | CFile::shareDenyWrite);
		DWORD iRead;
		CAutoBuffer buf(nBufSize);
		do
		{
			iRead = ReadFile(buf, buf.GetSize());
			if (iRead)
				f.Write(buf, iRead);
		}
		while (iRead == buf.GetSize());
		CloseFile(f);
	}	
	return true;
}
bool FStreamingNetworkPlatformFile::IsReadOnly(const TCHAR* Filename)
{
	FFileInfo Info;
	GetFileInfo(Filename, Info);

	return Info.ReadOnly;
}
FDateTime FStreamingNetworkPlatformFile::GetAccessTimeStamp(const TCHAR* Filename)
{
	FFileInfo Info;
	GetFileInfo(Filename, Info);

	return Info.AccessTimeStamp;
}
Exemplo n.º 12
0
// Finds the first file of a given directory. Must be used in conjunction with 
// the FindNext and FindClose methods. FindClose needn't be called if the call
// to FindFirst returned false.
//
// Returns:
//		true	if a file was found
//		false	if no file was found, or if there was an error
//
// Example:
//
//		CiPoTApi iPodApi;
//		t_iPodFileInfo info;
//		bool bFile;
//		t_iPodError status = iPodApi.OpenSession();
//
//		if (status == IPOD_ERR_OK) {
//			bFile = iPodApi.FindFirst(remotePath, &info);
//			while (bFile) {
//				printf("%s\n", info.findData.cFileName);
//				bFile = iPodApi.FindNext(&info);
//			}
//			iPodApi.FindClose(&info);
//
bool CiPoTApi::FindFirst(char *remotePath, t_iPodFileInfo *pInfo)
{
	t_AFCDirectory *pHandle;
	afc_error_t ret;
	char *pEntry;
	CMacPath MacPath;

	pInfo->pHandle = NULL;
	pInfo->remotePath = NULL;
	MacPath.SetWindowsPath(remotePath);
	ret = AFCDirectoryOpen(m_iPodConnection, MacPath.GetBuffer(), &pHandle);
	if (ret)
		return false;
	ret = AFCDirectoryRead(m_iPodConnection, pHandle, &pEntry);
	if (ret || pEntry == NULL) {
		// Broken link?
		AFCDirectoryClose(m_iPodConnection, pHandle);
		return false;
	}
	pInfo->remotePath = strdup(remotePath);
	pInfo->pHandle = pHandle;
	// Now, a special case with the Applications folder
	pInfo->appFolder = bTranslateApps && (
		!strcmp(remotePath, _T("\\User\\Applications")) ||
		!strcmp(remotePath, _T("\\var\\mobile\\Applications")) ||
		!strcmp(remotePath, _T("\\private\\var\\mobile\\Applications")));
	MacPath.SetString(pEntry);
	MacPath.GetWindowsPath(pInfo->findData.cFileName);
	GetFileInfo(0, pInfo);
	return true;
}
Exemplo n.º 13
0
HRESULT CMediaFileList::AddAudioFile(BSTR FilePath, IMediaFile **ppResult)
{
	HRESULT hr = CoCreateInstance(CLSID_MediaFile, NULL, 
							  CLSCTX_INPROC_SERVER, 
							  IID_IMediaFile, 
							  (void **)ppResult);

	if (FAILED(hr) || *ppResult == NULL)
		return E_POINTER;
	
	(*ppResult)->AddRef();
	(*ppResult)->put_FilePath(FilePath);
	
	double dDuration = 0;
	hr = GetFileInfo(FilePath, 0, &dDuration, 0, 0, 0, 0, 0, 0);
	
	if (SUCCEEDED(hr))
	{
		(*ppResult)->put_Duration(dDuration);
	}
	
	(*ppResult)->put_StartOffset(GetCurrentAudioLength());

	m_audioList.AddTail(*ppResult);
	
	(*ppResult)->AddRef();

	return S_OK;
}
Exemplo n.º 14
0
    static void GetAvailableThemes(std::vector<AvailableTheme> * outThemes)
    {
        Guard::ArgumentNotNull(outThemes, GUARD_LINE);

        outThemes->clear();

        NumPredefinedThemes = 0;
        for (auto predefinedTheme : PredefinedThemes)
        {
            AvailableTheme theme {};
            theme.Name = predefinedTheme.Theme->Name;
            outThemes->push_back(std::move(theme));

            NumPredefinedThemes++;
        }

        auto themesPattern = Path::Combine(GetThemePath(), "*.json");
        auto scanner = std::unique_ptr<IFileScanner>(Path::ScanDirectory(themesPattern, true));
        while (scanner->Next())
        {
            auto fileInfo = scanner->GetFileInfo();
            auto name = Path::GetFileNameWithoutExtension(std::string(fileInfo->Name));

            AvailableTheme theme {};
            theme.Name = name;
            theme.Path = GetThemeFileName(theme.Name);
            outThemes->push_back(std::move(theme));

            if (Path::Equals(CurrentThemePath, scanner->GetPath()))
            {
                ActiveAvailableThemeIndex = outThemes->size() - 1;
            }
        }
    }
Exemplo n.º 15
0
void mhmakefileparser::SetvPath(const string &Pattern, const string &Path)
{
  // First create the array of directory from the Path parameter. For now all entries need to
  // be valid directories (extra checking). This could be improved by checking if there
  // is a rule for creating the directory entry, but like first said, not for now.
  refptr<fileinfoarray> pDirArray=new fileinfoarray;

  const char *pTmp=Path.c_str();
  while (*pTmp)
  {
    string Item;
    pTmp=NextItem(pTmp,Item," \t:;");
    if (!Item.empty())
    {
      fileinfo *pDir=GetFileInfo(Item,m_MakeDir);
      if (!pDir->IsDir())
      {
        #ifdef WIN32
        // On windows this could happen if a full pathname was specified, so we try together
        // with the next item to check if this is not a valid directories
        // but only if the the length of the item was 1 namely the driver letter
        if (Item.length()==1)
        {
          string Rest;
          pTmp=NextItem(pTmp,Rest," \t:;");
          pDir=GetFileInfo(Item+":"+Rest,m_MakeDir);
          #ifdef _DEBUG
          if (g_PrintAdditionalInfo && !pDir->IsDir())
            throw(pDir->GetFullFileName()+" is not a valid directory.");
          #endif
        }
        #ifdef _DEBUG
        else if (g_PrintAdditionalInfo)
          cout << pDir->GetFullFileName() << " is not a valid directory.\n";
        #endif
        #else
        #ifdef _DEBUG
        if (g_PrintAdditionalInfo)
          cout << pDir->GetFullFileName() << " is not a valid directory.\n";
        #endif
        #endif
      }
      pDirArray->push_back(pDir);
    }
  }
  m_vPath.push_back(pair<string, refptr<fileinfoarray> >(Pattern,pDirArray));
}
Exemplo n.º 16
0
long
FileLoadDrivers( char * dirSpec, long plugin )
{
    long         ret, length, flags, time, bundleType;
    long long	 index;
    long         result = -1;
    const char * name;
 
    if ( !plugin )
    {
        // First try 10.6's path for loading Extensions.mkext.
        if (FileLoadMKext(dirSpec, "Caches/com.apple.kext.caches/Startup/") == 0)
            return 0;

        // Next try the legacy path.
        else if (FileLoadMKext(dirSpec, "") == 0)
          return 0;

        strcat(dirSpec, "Extensions");
    }

    index = 0;
    while (1) {
        ret = GetDirEntry(dirSpec, &index, &name, &flags, &time);
        if (ret == -1) break;

        // Make sure this is a directory.
        if ((flags & kFileTypeMask) != kFileTypeDirectory) continue;
        
        // Make sure this is a kext.
        length = strlen(name);
        if (strcmp(name + length - 5, ".kext")) continue;

        // Save the file name.
        strcpy(gFileName, name);
    
        // Determine the bundle type.
        sprintf(gTempSpec, "%s/%s", dirSpec, gFileName);
        ret = GetFileInfo(gTempSpec, "Contents", &flags, &time);
        if (ret == 0) bundleType = kCFBundleType2;
        else bundleType = kCFBundleType3;

        if (!plugin)
            sprintf(gDriverSpec, "%s/%s/%sPlugIns", dirSpec, gFileName,
                    (bundleType == kCFBundleType2) ? "Contents/" : "");

        ret = LoadDriverPList(dirSpec, gFileName, bundleType);

        if (result != 0)
          result = ret;

        if (!plugin) 
          FileLoadDrivers(gDriverSpec, 1);
    }

    return result;
}
Exemplo n.º 17
0
void HibernateEnabler_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6)
{
    bool tryresume,tryresumedefault, forceresume;

    if (!getBoolForKey (kWake, &tryresume, DEFAULT_BOOT_CONFIG))
    {
        tryresume = true;
        tryresumedefault = true;
    }
    else
    {
        tryresumedefault = false;
    }

    if (!getBoolForKey (kForceWake, &forceresume, DEFAULT_BOOT_CONFIG))
    {
        forceresume = false;
    }

    if (forceresume)
    {
        tryresume = true;
        tryresumedefault = false;
    }

    while (tryresume) {
        const char *tmp, *val;
        int len, ret = -1;
        long flags, sleeptime;
        BVRef bvr;
        if (!getValueForKey(kWakeImage, &val, &len, DEFAULT_BOOT_CONFIG))
            val="/private/var/vm/sleepimage";

        // Do this first to be sure that root volume is mounted
        ret = GetFileInfo(0, val, &flags, &sleeptime);

        if ((bvr = getBootVolumeRef(val, &tmp)) == NULL)
            break;

        // Can't check if it was hibernation Wake=y is required
        if (bvr->modTime == 0 && tryresumedefault)
            break;

        if ((ret != 0) || ((flags & kFileTypeMask) != kFileTypeFlat))
            break;

        if (!forceresume && ((sleeptime+3)<bvr->modTime))
        {
            printf ("Hibernate image is too old by %d seconds. Use ForceWake=y to override\n",bvr->modTime-sleeptime);
            break;
        }

        HibernateBoot((char *)val);
        break;
    }

}
Exemplo n.º 18
0
int KHttpFile::Download()
{
    int nRetCode    = false;
    int nResult     = false;
    int nRetryCount = 0;

    nRetCode = GetFileInfo();
    KGLOG_PROCESS_ERROR(nRetCode);

    while (nRetryCount <= 5)
    {
        if (m_nFileSize == m_nDownloadedSize)
        {
            m_nErrorCode = dec_err_success;
            goto Exit1;
        }

        nRetCode = m_Downloader.Download(m_strUrl.c_str(), m_strFile.c_str());
        switch(nRetCode)
        {
        case HTTP_RESULT_SUCCESS:
        case HTTP_RESULT_SAMEAS:
            m_nErrorCode = dec_err_success;
            goto Exit1;
            break;

        case HTTP_RESULT_STOP:
            m_nErrorCode = dec_err_stop;
            goto Exit0;
            break;

        case HTTP_RESULT_FAIL:
            m_nErrorCode = dec_err_disconnection;
            KGLogPrintf(KGLOG_INFO, "disconnection retry %d", nRetryCount++);
            Sleep(5000);
            break;

        case HTTP_RESULT_REDIRECT_FTP:
        case HTTP_RESULT_REDIRECT_HTTP:
            m_nErrorCode = dec_err_cannotconnect;
            KGLogPrintf(KGLOG_INFO, "cannotconnect retry %d", nRetryCount++);
            Sleep(5000);
            break;

        default:
            m_nErrorCode = dec_err_cannotconnect;
            KGLOG_PROCESS_ERROR(false && "unknow result");
            break;
        }
    }

Exit1:
    nResult = true;
Exit0:
    KGLogPrintf(KGLOG_INFO, "download result= %d, filename = %s", m_nErrorCode, m_strFile.c_str());
    return nResult;
}
Exemplo n.º 19
0
CDateTime CLocalFileSystem::GetModificationTime( const wxString& path)
{
	CDateTime mtime;

	bool tmp;
	if (GetFileInfo(path, tmp, 0, &mtime, 0) == unknown)
		mtime = CDateTime();

	return mtime;
}
Exemplo n.º 20
0
// This is called once for each output line.
// In this example the input data is obtained pixel by pixel from the input image
// using the GetPixel method of the GDI+ Bitmap object created from the source image
// file above.
//
CNCSError ECWDEMCompressor::WriteReadLine(UINT32 nNextLine, void **ppInputArray)
{
    CNCSError Error = NCS_SUCCESS;
    NCSFileViewFileInfoEx *pInfo = GetFileInfo();

    IFECW->WriteReadLineCallback(nNextLine, ppInputArray, pInfo->nSizeX, pInfo->eCellType);

    return NCS_SUCCESS;

} // ECWDEMCompressor::WriteReadLine
Exemplo n.º 21
0
BOOL CUnzipper::GetFileInfo(int nFile, UZ_FileInfo& info)
{
	if (!m_uzFile)
		return FALSE;

	if (!GotoFile(nFile))
		return FALSE;

	return GetFileInfo(info);
}
Exemplo n.º 22
0
FileWatcher::FileEventFlags FileWatcher::Worker::UpdateFileInfo(boost::filesystem::path path)
{
	FileEventFlags flags = FileEventFlags::Nothing;
	if (boost::filesystem::exists(path))
	{
		FileInfo fi = GetFileInfo(path);
		auto lastFileInfoIt = m_FileInfo.find(path);
		if (lastFileInfoIt != m_FileInfo.end())
		{
			FileInfo lastFileInfo = lastFileInfoIt->second;

			if (fi.Size != lastFileInfo.Size)
			{
				LOG_DEBUG("FileWatcher: \"%s\" size changed!", path.string().c_str());
				flags = flags | FileEventFlags::SizeChanged;
			}
			if (fi.Timestamp != lastFileInfo.Timestamp)
			{
				LOG_DEBUG("FileWatcher: \"%s\" timestamp changed!", path.string().c_str());
				flags = flags | FileEventFlags::TimestampChanged;

			}
		}
		else
		{
			LOG_DEBUG("FileWatcher: \"%s\" was created!", path.string().c_str());
			flags = flags | FileEventFlags::Created;
		}
		m_FileInfo[path] = GetFileInfo(path);
	}
	else
	{
		auto fileInfoIt = m_FileInfo.find(path);
		if (fileInfoIt != m_FileInfo.end())
		{
			m_FileInfo.erase(fileInfoIt);
			LOG_DEBUG("FileWatcher: \"%s\" was deleted!", path.string().c_str());
			flags = flags | FileEventFlags::Deleted;
		}
	}
	return flags;
}
Exemplo n.º 23
0
wxLongLong CLocalFileSystem::GetSize(wxString const& path, bool* isLink)
{
	wxLongLong ret = -1;
	bool tmp{};
	local_fileType t = GetFileInfo(path, isLink ? *isLink : tmp, &ret, 0, 0);
	if( t != file ) {
		ret = -1;
	}

	return ret;
}
Exemplo n.º 24
0
bool CServerFileManageHandle::DowndFileDir(LPCWSTR szPath, LPCWSTR szRemote)
{
	std::wstring strPath = szRemote;
	
	if( szPath[lstrlen(szPath) -1] != _T('\\') )
		strPath +=  _T("\\");
	{{
		std::wstring strPath = szPath;
		if( szPath[lstrlen(szPath) -1] != _T('\\') )
			strPath +=  _T("\\");
		BOOL bOK = CreateDirectory(strPath.c_str(), NULL);
		if(!bOK)
			return false;
	}}
	
	File_Info_Vector Vector;
	bool bIsOk = GetFileInfo(strPath.c_str(), &Vector);
	if(!bIsOk)
		return false;
	DWORD dwFileCount = Vector.size();
	for(DWORD i = 0; i < Vector.size(); i++)
	{
		if(lstrcmp(Vector[i].cFileName, _T(".")) == 0)
			continue;
		if(lstrcmp(Vector[i].cFileName, _T("..")) == 0)
			continue;			
		std::wstring strPath = szPath;
		if( szPath[lstrlen(szPath) -1] != _T('\\') )
			strPath +=  _T("\\");

		std::wstring strRemote = szRemote;
		if( szRemote[lstrlen(szRemote) -1] != _T('\\') )
			strRemote +=  _T("\\");
		if(Vector[i].bIsDir)
		{
			strPath +=  Vector[i].cFileName;
			strPath +=  _T("\\");
			strRemote += Vector[i].cFileName;
			strRemote +=  _T("\\");
			bIsOk = DowndFileDir(strPath.c_str(), strRemote.c_str());
			if(!bIsOk)
				return false;
		}
		else
		{
			strPath +=  Vector[i].cFileName;
			strRemote += Vector[i].cFileName;
			bIsOk = DowndFile(strPath.c_str(), strRemote.c_str());
			if(!bIsOk)
				return false;
		}
	}
	return true;
}
Exemplo n.º 25
0
void FileWatcher::Worker::AddWatch(std::string path, FileEventCallback_t callback)
{
	m_Mutex.lock();
	boost::filesystem::path bpath(path);
	m_FileCallbacks[bpath] = callback;
	if (boost::filesystem::exists(bpath))
	{
		m_FileInfo[bpath] = GetFileInfo(bpath);
	}
	m_Mutex.unlock();
}
Exemplo n.º 26
0
void LogException(BadCodeException &e) {
  try {
    auto info = GetFileInfo(e.location);
    std::cerr << info.generateReport(e.message) << std::endl;
  } catch (InternalCompilerError &ice) {
    std::cerr << ice.message << " The error was: '" << e.message << "'"
              << std::endl;
  } catch (...) {
    std::cerr << "There was an error in the above program." << std::endl;
    // And the above compiler, apparently
  }
}
Exemplo n.º 27
0
void mhmakefileparser::SplitToItems(const string &String,vector<fileinfo*> &Items) const
{
  const char *pTmp=String.c_str();
  while (*pTmp)
  {
    string Item;
    pTmp=NextItem(pTmp,Item);
    if (!Item.empty())
    {
      Items.push_back(GetFileInfo(Item,m_MakeDir));
    }
  }
}
Exemplo n.º 28
0
void mhmakefileparser::ParseBuildedIncludeFiles()
{
  vector<string>::iterator It=m_ToBeIncludeAfterBuild.begin();
  while (It!=m_ToBeIncludeAfterBuild.end())
  {
    int result=ParseFile(GetFileInfo(*It,m_MakeDir));
    if (result)
    {
      throw string("Error parsing ")+*It;
    }
    It++;
  }
}
Exemplo n.º 29
0
//根据MD5值返回文件全路径
acl::string CResourceMgr::GetFileFullPath(acl::string md5)
{
    acl::string info = GetFileInfo(md5);
    std::vector<acl::string> vField = info.split2(SPLITOR_OF_FILE_INFO);
    if (vField.size() > 3)
    {
        //key:md5, value:文件名|文件路径|MD5|文件大小

        return vField[1];
    }

    return "";
}
Exemplo n.º 30
0
bool Buffer::LoadFromFile(std::string filename, SoundType sound)
{
    m_sound = sound;
    GetLogger()->Debug("Loading audio file: %s\n", filename.c_str());

    auto file = CResourceManager::GetSNDFileHandler(filename);

    GetLogger()->Trace("  channels %d\n", file->GetFileInfo().channels);
    GetLogger()->Trace("  format %d\n", file->GetFileInfo().format);
    GetLogger()->Trace("  frames %d\n", file->GetFileInfo().frames);
    GetLogger()->Trace("  samplerate %d\n", file->GetFileInfo().samplerate);
    GetLogger()->Trace("  sections %d\n", file->GetFileInfo().sections);

    if (!file->IsOpen())
    {
        GetLogger()->Warn("Could not load file %s. Reason: %s\n", filename.c_str(), file->GetLastError().c_str());
        m_loaded = false;
        return false;
    }

    alGenBuffers(1, &m_buffer);
    if (CheckOpenALError())
    {
        GetLogger()->Warn("Could not create audio buffer. Code: %d\n", GetOpenALErrorCode());
        m_loaded = false;
        return false;
    }

    // read chunks of 4096 samples
    std::vector<uint16_t> data;
    std::array<int16_t, 4096> buffer;
    data.reserve(file->GetFileInfo().frames);
    std::size_t read = 0;
    while ((read = file->Read(buffer.data(), buffer.size())) != 0)
    {
        data.insert(data.end(), buffer.begin(), buffer.begin() + read);
    }

    ALenum format = file->GetFileInfo().channels == 1 ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16;
    alBufferData(m_buffer, format, &data.front(), data.size() * sizeof(uint16_t), file->GetFileInfo().samplerate);
    m_duration = static_cast<float>(file->GetFileInfo().frames) / file->GetFileInfo().samplerate;
    m_loaded = true;
    return true;
}