Ejemplo n.º 1
0
BOOL CFileView::RenameFile(CString strNewName, HTREEITEM hItem)
{
	CString strOldName = m_wndFileView.GetItemText(hItem);
	DWORD dwInfo = m_wndFileView.GetItemData(hItem);
	if(dwInfo == INFO_FILE)
	{
		if(FindSkinFile(CGlobalVariable::m_strProjectPath + strOldName))
		{
			MessageBox(_T("此文件正处于打开状态,请先关闭后再进行重命名。"), _T("提示"), MB_ICONINFORMATION);
			return FALSE;
		}
		if(!MoveFile(CGlobalVariable::m_strProjectPath + strOldName
			, CGlobalVariable::m_strProjectPath + strNewName))
		{
			MessageBox(_T("此文件已经存在,不能重复命名。"), _T("提示"), MB_ICONINFORMATION);
			return FALSE;
		}
	}
	else if(dwInfo == INFO_DIRECTORY)
	{
		if(FindDirectory(strNewName, m_wndFileView.GetParentItem(hItem)))
		{
			MessageBox(_T("此目录已经存在,不能重复命名。"), _T("提示"), MB_ICONINFORMATION);
			return FALSE;
		}
	}

	return TRUE;
}
Ejemplo n.º 2
0
void FServerTOC::AddFileOrDirectory(const FString& Filename, const FDateTime& Timestamp)
{
	// File name
	const FString Path = FPaths::GetPath(Filename);
	FDirectory* ServerPathDirectory = FindDirectory(Path);
	if (ServerPathDirectory == NULL)
	{
		ServerPathDirectory = new FDirectory();
		Directories.Add(Path, ServerPathDirectory);
	}
	// Directories have timestamp = 0, in this case try to add the directory too (GetPath returns the parent directory)
	if (Timestamp == 0)
	{			
		FDirectory* ServerFilenameDirectory = FindDirectory(Filename);
		if (ServerFilenameDirectory == NULL)
		{
			Directories.Add(Filename, new FDirectory());
		}
	}
	// Add file or directory to this directory.
	ServerPathDirectory->Add(Filename, Timestamp);
}
Ejemplo n.º 3
0
void CFileView::OnDirectoryNew()
{
	// TODO: 在此添加命令处理程序代码
	HTREEITEM hSelectedItem = m_wndFileView.GetSelectedItem();
	DWORD dwInfo = m_wndFileView.GetItemData(hSelectedItem);
	HTREEITEM hParent = (dwInfo != INFO_FILE) ? hSelectedItem:m_wndFileView.GetParentItem(hSelectedItem);
	int nCount = 2;
	CString strDirName = _T("新建文件夹");
	while(FindDirectory(strDirName, hParent))
		strDirName.Format(_T("新建文件夹(%d)"), nCount++);

	HTREEITEM hNewItem = m_wndFileView.InsertItem(strDirName, 1, 1, hParent);
	m_wndFileView.SetItemData(hNewItem, INFO_DIRECTORY);
	m_wndFileView.Expand(hParent, TVE_EXPAND);
	m_wndFileView.SelectItem(hNewItem);
	m_wndFileView.EditLabel(hNewItem);
}
Ejemplo n.º 4
0
/* ------------------- D R E A M  -  D O C -------------------------------
** Nom        : 
** Entree(s)  : 
** Sortie(s)  : 
** Val de ret : 
** Sujet      : 
** Dependance : 
** Auteur     : Olivier Juan
** Version    : 
------------------------------------------------------------------------*/
Iso9660File *IsoFOpen(unsigned char *tname)
{
  Iso9660File *f=NULL;
  FileDescriptor *FD;
  int r,i,j;
  unsigned char *uname;
  r=strlen(tname);
  if (tname[0]==SEPARATOR)
    {
      uname=(unsigned char *)malloc(r+1);
      for (i=0;i<strlen(tname);i++)uname[i]=tname[i];
    }
  else
    {
      j=0;
      uname=(unsigned char *)malloc(strlen(DefaultDir)+r+1);
      for (i=0;i<strlen(DefaultDir);i++)uname[i]=DefaultDir[i];
      for (;j<strlen(tname);i++,j++)uname[i]=tname[j];
    }
  uname[i]=0;
  if ((r=SimplifyDirectory(uname)) !=0)
    {
      printf("Erreur dans SimplifyDirectory :%d\n",r);
      return 1;
      //exit(1);
    }
  if ((r=FindDirectory(uname,&FD)) !=0)
    {
      printf("Erreur dans FindDirectory :%d\n",r);
      exit(2);
    }
  f=(Iso9660File *)malloc(sizeof(Iso9660File));
  f->FirstSector=FD->FileFirstSectorNum;
  f->Open=1;
  f->Position=0;
  f->SectorNumber=0;
  f->SectorOffset=0;
  f->Size=FD->FileFirstSectorNbr;
  f->Flag=FD->FileFlag;
  free(FD);
  free(uname);
  return f;
}
Ejemplo n.º 5
0
bool FileStorage::SearchFilesToExtract(const StringRef& searchPath, bool isRecursively /*= true*/, const StringRef& outDir /*= StringRef::Empty*/)
{
	if (Path::IsDirectory(searchPath))
	{
		return ExtractDirectory(searchPath, nullptr, isRecursively, outDir);
	}
	else
	{
		if (Path::HasSearchPattern(searchPath))
		{
			List<HeapString> outFiles;
			FileInfo fileInfo(searchPath);
			auto dir = fileInfo.Directory();
			auto* dirEntry = FindDirectory(dir);
			RETURN_FALSE_IF_NULL(dirEntry);
			return dirEntry->SearchFilesToExtract(fileInfo.FullName(), isRecursively, outDir);
		}
		else
		{
			return ExtractFile(searchPath, nullptr, outDir);
		}
	}
}
Ejemplo n.º 6
0
bool FileStorage::SearchFilesToRemove(const StringRef& searchPath, bool isRecursively /*= true*/)
{
	if (Path::IsDirectory(searchPath))
	{
		return RemoveDirectory(searchPath);
	}
	else
	{
		if (Path::HasSearchPattern(searchPath))
		{
			List<HeapString> outFiles;
			FileInfo fileInfo(searchPath);
			auto dir = fileInfo.Directory();
			auto* dirEntry = FindDirectory(dir);
			RETURN_FALSE_IF_NULL(dirEntry);
			return dirEntry->SearchFilesToRemove(fileInfo.FullName(), isRecursively);
		}
		else
		{
			return RemoveFile(searchPath);
		}
	}
}
Ejemplo n.º 7
0
bool FileStorage::RemoveAllFiles(const StringRef& path)
{
	auto* parent = FindDirectory(path);
	RETURN_FALSE_IF_NULL(parent);
	return RemoveAllFiles(*parent);
}
Ejemplo n.º 8
0
bool FileStorage::ExtractDirectory(const StringRef& path, DirectoryEntry* parent /*= nullptr*/, bool isRecursively /*= true*/, const StringRef& outDir /*= StringRef::Empty*/) const
{
	auto* dirEntry = FindDirectory(path, parent);
	return dirEntry->Extract(outDir, isRecursively);
}
Ejemplo n.º 9
0
bool FileStorage::RemoveAll(const StringRef& path, DirectoryEntry* parent /*= nullptr*/)
{
	parent = FindDirectory(path, parent);
	RETURN_FALSE_IF_NULL(parent);
	return RemoveAll(*parent);
}
Ejemplo n.º 10
0
bool FileStorage::RemoveDirectory(const StringRef& path, DirectoryEntry* parent /*= nullptr*/)
{
	return RemoveDirectory(const_cast<DirectoryEntry*>(FindDirectory(path, parent)));
}
Ejemplo n.º 11
0
BOOL CALLBACK MODDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
   HANDLE hFile = NULL;
   char path[MAX_PATH];
   char dirname[MAX_PATH];
   char filename[MAX_PATH];
   int i;
   int count = 0;
   struct stat stat_str;

   switch (uMsg)
   {
      case WM_INITDIALOG:

         if (!CenterWindow( hDlg ))
            return( FALSE );

         strcpy(path, szParentPath);
         strcat(path, "\\*");

         while ((hFile = FindDirectory(hFile, dirname, path)) != NULL)
         {
            if ((strcmp(dirname, ".") == 0) || (strcmp(dirname, "..") == 0))
               continue;

            strcpy(filename, szParentPath);
            strcat(filename, "\\");
            strcat(filename, dirname);
            strcat(filename, "\\liblist.gam");

            if (stat(filename, &stat_str) == 0)
            {
               SendDlgItemMessage(hDlg, IDC_MOD, CB_ADDSTRING, 0, (LPARAM)((LPCSTR)dirname));
               count++;
            }
         }

         if (count == 0)
         {
            MessageBox (NULL, "Can't find any MOD directories\nAre you sure you have things installed right?", NULL, MB_OK);
            g_ReturnStatus = IDCANCEL;
            EndDialog(hDlg, TRUE);
            return ( TRUE );
         }

         SendDlgItemMessage(hDlg, IDC_MOD, CB_SETCURSEL, 0, 0L);

         return TRUE;

      case WM_COMMAND:
         switch ((WORD) wParam)
         {
            case IDOK:
               i = SendDlgItemMessage(hDlg, IDC_MOD, CB_GETCURSEL, 0, 0L);

               SendDlgItemMessage(hDlg, IDC_MOD, CB_GETLBTEXT, i, (LPARAM)((LPCSTR)g_szMODdir));

               g_ReturnStatus = IDOK;
               EndDialog(hDlg, TRUE);
               return ( TRUE );

            case IDCANCEL:
               g_ReturnStatus = IDCANCEL;
               EndDialog(hDlg, TRUE);
               return ( TRUE );
         }
         break;
   }

   return FALSE;
}
Ejemplo n.º 12
0
void LoadBotModels(void)
{
   char game_dir[256];
   char path[MAX_PATH];
   char search_path[MAX_PATH];
   char dirname[MAX_PATH];
   char filename[MAX_PATH];
   int index;
   struct stat stat_str;
#ifndef __linux__
   HANDLE directory = NULL;
#else
   DIR *directory = NULL;
#endif

   for (index=0; index < MAX_SKINS; index++)
      bot_skins[index].skin_used = FALSE;

   number_skins = VALVE_MAX_SKINS;
   if(submod_id == SUBMOD_OP4)
      number_skins += GEARBOX_MAX_SKINS;

   for (index=0; index < number_skins; index++)
   {
      safe_strcopy(bot_skins[index].model_name, sizeof(bot_skins[index].model_name), default_bot_models[index]);
      safe_strcopy(bot_skins[index].bot_name, sizeof(bot_skins[index].bot_name), default_bot_names[index]);
   }

   // find the directory name of the currently running MOD...
   GetGameDir (game_dir);

   safevoid_snprintf(path, sizeof(path), "%s/models/player", game_dir);

   if (stat(path, &stat_str) != 0)
   {
      // use the valve/models/player directory if no MOD models/player
      strcpy(path, "valve/models/player");
   }

#ifndef __linux__
   safevoid_snprintf(search_path, sizeof(search_path), "%s/*", path);
#else
   strcpy(search_path, path);
#endif

   while ((directory = FindDirectory(directory, dirname, sizeof(dirname), search_path)) != NULL)
   {
      if ((strcmp(dirname, ".") == 0) || (strcmp(dirname, "..") == 0))
         continue;

      safevoid_snprintf(filename, sizeof(filename), "%s/%s/%s.mdl", path, dirname, dirname);

      if (stat(filename, &stat_str) == 0)
      {
         // add this model to the array of models...
         for (index=0; dirname[index]; index++)
            dirname[index] = tolower(dirname[index]);

         // check for duplicate...
         for (index=0; index < number_skins; index++)
         {
            if (strcmp(dirname, bot_skins[index].model_name) == 0)
               break;
         }

         if (index == number_skins)
         {
            // add this model to the bot_skins array...
            safe_strcopy(bot_skins[number_skins].model_name, sizeof(bot_skins[number_skins].model_name), dirname);

            dirname[0] = toupper(dirname[0]);
            safe_strcopy(bot_skins[number_skins].bot_name, sizeof(bot_skins[number_skins].bot_name), dirname);

            number_skins++;
         }
      }

      if (number_skins == MAX_SKINS)
         break;  // break out if max models reached
   }
}