Example #1
0
bool save_login()
{
	Json::Value login;

	login["pwd"] = base64::base64_encode((UCHAR*)XorCrypt::Xor(login_pwd, XOR_PWD).c_str(), login_pwd.length());
	login["user"] = login_name;

	TCHAR szPath[MAX_PATH] = { 0 };
	SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, szPath);
	::PathAppend(szPath, APP_NAME);

	if (!PathFileExists(szPath))
	{
		SHCreateDirectoryEx(NULL, szPath, NULL);
	}

	::PathAppend(szPath, LOGIN_DAT);

	HANDLE hFile = CreateFile(szPath, GENERIC_WRITE | GENERIC_READ,
		0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
	if (hFile == INVALID_HANDLE_VALUE)
		return false;
	DWORD dwWritten = 0;
	::WriteFile(hFile, login.toStyledString().c_str(), login.toStyledString().size(), &dwWritten, NULL);
	::FlushFileBuffers(hFile);
	::CloseHandle(hFile);

	return true;
}
Example #2
0
bool MakeDirectoryRecursive(const char* path)
{
#ifdef _WIN32
  return SHCreateDirectoryEx( NULL, path, NULL ) == ERROR_SUCCESS;
#else
        size_t len = strlen(path);
        char* tmp = new char[len+1];
        char *p = NULL;
 
        strcpy(tmp, path);
        if(tmp[len - 1] == '/')
                tmp[len - 1] = 0;
	p = tmp;
	if(*p == '/') p++;
        for(; *p; p++)
                if(*p == '/') {
                        *p = 0;
                        mkdir(tmp, S_IRWXU);
                        *p = '/';
                }
        bool res=( mkdir(tmp, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) == 0);
	delete [] tmp;
	return res;
#endif
}
Example #3
0
void regInit(const char *path, bool force)
{
	if( regEnabled ) {
  DWORD disp = 0;
  LONG res = RegCreateKeyEx(HKEY_CURRENT_USER,
                            "Software\\Emulators\\VisualBoyAdvance",
                            0,
                            "",
                            REG_OPTION_NON_VOLATILE,
                            KEY_ALL_ACCESS,
                            NULL,
                            &vbKey,
                            &disp);
	}
  if( regVbaPath != NULL ) {
	  delete regVbaPath;
	  regVbaPath = NULL;
  }

  // If vbam.ini exists in executable's folder, use it. Else create/use one in %appdata% folder.
  regVbaPath = new CString();
  regVbaPath->Format(MakeInstanceFilename("%s\\vbam.ini"), path);
  if( !force && !utilFileExists( regVbaPath->GetString() ) ) {
	  TCHAR appdata[MAX_PATH+1];
	  SHGetFolderPath( NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, appdata );
	  regVbaPath->Format( "%s\\VBA-M", appdata );
	  SHCreateDirectoryEx( NULL, regVbaPath->GetString(), NULL );
	  regVbaPath->Append( "\\vbam.ini" );
  }
}
Example #4
0
/*
* 打印日志文件
*/
void CServerGameDesk::DebugPrintf(const char *p, ...)
{
	if(!m_bWriteLog || NULL == m_pDataManage)
	{
		return;
	}
	return;
	char szFilename[256];
	CString strPath = CINIFile::GetAppPath() +"\\GameLog\\";

	SHCreateDirectoryEx(NULL, strPath, NULL);

	CTime time = CTime::GetCurrentTime();

	sprintf(szFilename, "%s%d_%d_%d_%d%d%d_log.txt",strPath ,NAME_ID,m_pDataManage->m_InitData.uRoomID,m_bDeskIndex,time.GetYear(), time.GetMonth(), time.GetDay());
	FILE *fp = fopen( szFilename, "a" );
	if (NULL == fp)
	{
		return;
	}

	//插入时间
	char cTime[30];
	::memset(cTime,0,sizeof(cTime));
	sprintf(cTime,"[%d:%d:%d] ",time.GetHour(),time.GetMinute(),time.GetSecond());
	fprintf(fp,cTime);

	va_list arg;
	va_start( arg, p );
	vfprintf(fp, p, arg );
	fprintf(fp,"\n");

	fclose(fp);
}
Example #5
0
void DebugPrintf2(int iRoomID, const char *p, ...)
{
	OutputDebugString("wx DebugPrintf2");
	/*if(!m_bWriteLog)
	{
	return ; 
	}*/
	return;
	char szFilename[1024];
	CString strPath = CINIFile::GetAppPath() +"\\GameLog\\";

	SHCreateDirectoryEx(NULL, strPath, NULL);

	CTime time = CTime::GetCurrentTime();

	sprintf(szFilename, "%s%d_%d-%d%d%d%d-log.txt",
		strPath , NAME_ID, iRoomID, time.GetYear(), time.GetMonth(), time.GetDay(),time.GetHour());
	FILE *fp = fopen( szFilename, "a" );
	if (NULL == fp)
	{
		return;
	}
	va_list arg;
	va_start( arg, p );
	vfprintf(fp, p, arg );
	fprintf(fp,"\n");
	fclose(fp);
}
BOOL CNCaptureView::ShowImageInMsPaint()
{
	BOOL bRet = FALSE;
	HRESULT hr = E_FAIL;

	if (m_pImage) // && !m_pImage->IsNull())
	{
		TCHAR szSavePath[MAX_PATH] = {0};
		API_VERIFY(SHGetSpecialFolderPath(NULL, szSavePath, CSIDL_MYDOCUMENTS , TRUE));
		if (bRet)
		{
			CString strFilePath(szSavePath);
			strFilePath += TEXT("\\nCapture\\mspaint\\");
			COM_VERIFY_EXCEPT1(SHCreateDirectoryEx(NULL, strFilePath, NULL), ERROR_ALREADY_EXISTS);

			//CTime now = CTime::GetCurrentTime();
			//strFilePath.AppendFormat(TEXT("%04d-%02d-%02d %02d-%02d-%02d.PNG"), 
			//	now.GetYear(), now.GetMonth(), now.GetDay(),
			//	now.GetHour(), now.GetMinute(), now.GetSecond());
		    CString strName = m_pImage->GetFileName();
			strFilePath.AppendFormat(TEXT("%s"), strName);
			COM_VERIFY(m_pImage->Save(strFilePath, Gdiplus::ImageFormatPNG));
			if (SUCCEEDED(hr))
			{
				m_pImage->SetEditTmpFile(strFilePath);
				return _EditWithMspaint(strFilePath);
			}
		}
	}
	return _EditWithMspaint(NULL);
}
BOOL CNCaptureView::ShowImageInPhotoEditor()
{
	BOOL bRet = FALSE;
	HRESULT hr = E_FAIL;

	if (m_pImage) // && !m_pImage->IsNull())
	{
		TCHAR szSavePath[MAX_PATH] = {0};
		API_VERIFY(SHGetSpecialFolderPath(NULL, szSavePath, CSIDL_MYDOCUMENTS , TRUE));
		if (bRet)
		{
			CString strFilePath(szSavePath);
			strFilePath += TEXT("\\nCapture\\Editor\\");
			COM_VERIFY_EXCEPT1(SHCreateDirectoryEx(NULL, strFilePath, NULL), ERROR_ALREADY_EXISTS);

			CString strName = m_pImage->GetFileName();
			strFilePath.AppendFormat(TEXT("%s"), strName);
			if (m_pImage->SaveImageFile(strFilePath))
			{
				return _EditWithPhotoEditor(strFilePath);
			}
		}
	}
	return FALSE;
}
Example #8
0
//压缩日志
void CLogTrace::CompressLogzip(const CString &strLogFileName)
{
	time_t tim;
	time(&tim);
	struct tm *t;

	t = localtime(&tim);
	//先压缩
	CString strName;
	CString strFilename;
	CString strTmpFile;
	strFilename = strLogFileName.Left(strLogFileName.GetLength() - 4);
	strName.Format(_T("%s_%04d%02d%02d%02d%02d%02d.zip"), strFilename.GetString(), 1900 + t->tm_year, 1 + t->tm_mon, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
	DWORD dwCode = ZipUtils::CompressFileToZip(strLogFileName, strName);
	/*CopyFile(m_szFullLogFileName, strDate.GetBuffer(), FALSE);*/
	//移动到备份文件夹
	int iPos = strName.ReverseFind(_T('\\'));
	strFilename = strName.Right(strName.GetLength() - iPos);
	TCHAR szPath[MAX_PATH] = { 0 };
	if (GetModuleFileName(NULL, szPath, MAX_PATH))
	{
		PathAppend(szPath, _T("..\\..\\..\\bak\\masterz"));
		SHCreateDirectoryEx(NULL, szPath, NULL);
		strTmpFile.Format(_T("%s%s"), szPath, strFilename.GetString());
		MoveFile(strName, strTmpFile);
	}
		
}
Example #9
0
//複数階層のディレクトリを一気に作成する
BOOL UtilMakeSureDirectoryPathExists(LPCTSTR _lpszPath)
{
#if defined(_UNICODE)||defined(UNICODE)
	CPath path(_lpszPath);
	path.RemoveFileSpec();
	path.AddBackslash();

	//TODO:UNICODE版のみでチェックを入れているのでANSIビルド時には適宜処理し直すべき
	CString tmp(path);
	if(-1!=tmp.Find(_T(" \\"))||-1!=tmp.Find(_T(".\\"))){	//パスとして処理できないファイル名がある
		ASSERT(!"Unacceptable Directory Name");
		return FALSE;
	}

	//UNICODE版のみで必要なチェック
	if(path.IsRoot())return TRUE;	//ドライブルートなら作成しない(できない)

	int nRet=SHCreateDirectoryEx(NULL,path,NULL);
	switch(nRet){
	case ERROR_SUCCESS:
		return TRUE;
	case ERROR_ALREADY_EXISTS:
		if(path.IsDirectory())return TRUE;	//すでにディレクトリがある場合だけセーフとする
		else return FALSE;
	default:
		return FALSE;
	}
#else//defined(_UNICODE)||defined(UNICODE)
  #pragma comment(lib, "Dbghelp.lib")
	return MakeSureDirectoryPathExists(_lpszPath);
#endif//defined(_UNICODE)||defined(UNICODE)
}
Example #10
0
void
FileMonitor::createFilePathAndCopy(wstring* logPath, wstring* filePath)
{
	printf("Copying file: %ls\n", filePath->c_str());
	wstring drive = filePath->substr(0,filePath->find_first_of(L":"));
	wstring fileName = filePath->substr(filePath->find_last_of(L"\\")+1);
	wstring intermediateDirectory = *logPath;
	intermediateDirectory += drive;
	intermediateDirectory += L"\\";
	intermediateDirectory += filePath->substr(filePath->find_first_of(L"\\")+1,filePath->find_last_of(L"\\")-filePath->find_first_of(L"\\")-1);
	SHCreateDirectoryEx(NULL,
							intermediateDirectory.c_str(),
							NULL
							);
	wstring filePathAndName = intermediateDirectory;
	filePathAndName += L"\\";
	filePathAndName += fileName;
	if(!CopyFile(
		filePath->c_str(),
		filePathAndName.c_str(),
		FALSE
		))
	{
		printf("\t... failed: 0x%08x\n", GetLastError());
	} else {
		printf("\t... done\n");
	}
}
Example #11
0
std::string GetPiUserDir(const std::string &subdir)
{
	// i think this test only works with glibc...
#if _GNU_SOURCE
	const char *homedir = getenv("HOME");
	std::string path = join_path(homedir, ".pioneer", 0);
	DIR *dir = opendir(path.c_str());
	if (!dir) {
		if (mkdir(path.c_str(), 0770) == -1) {
			Gui::Screen::ShowBadError(stringf(128, "Error: Could not create or open '%s'.", path.c_str()).c_str());
		}
	}
	closedir(dir);
	if (subdir != "") {
		path = join_path(homedir, ".pioneer", subdir.c_str(), 0);
		dir = opendir(path.c_str());
		if (!dir) {
			if (mkdir(path.c_str(), 0770) == -1) {
				Gui::Screen::ShowBadError(stringf(128, "Error: Could not create or open '%s'.", path.c_str()).c_str());
			}
		}
		closedir(dir);
	}
	return path+"/";
#elif _WIN32
	try {
		TCHAR path[MAX_PATH];
		if(S_OK != SHGetFolderPath(0, CSIDL_LOCAL_APPDATA, 0, SHGFP_TYPE_CURRENT, path))
			throw std::runtime_error("SHGetFolderPath");

		TCHAR temp[MAX_PATH];
		MultiByteToWideChar(CP_ACP, 0, "Pioneer", strlen("Pioneer")+1, temp, MAX_PATH);
		if(!PathAppend(path, temp))
			throw std::runtime_error("PathAppend");

		if (subdir != "") {
			MultiByteToWideChar(CP_ACP, 0, subdir.c_str(), subdir.size()+1, temp, MAX_PATH);
			if(!PathAppend(path, temp))
				throw std::runtime_error("PathAppend");
		}

		if(!PathFileExists(path) && ERROR_SUCCESS != SHCreateDirectoryEx(0, path, 0))
			throw std::runtime_error("SHCreateDirectoryEx");

		char temp2[MAX_PATH];
		WideCharToMultiByte(CP_ACP, 0, path, wcslen(path)+1, temp2, MAX_PATH, 0, 0);
		return std::string(temp2)+"/";
	}
	catch(const std::exception&) {
		Gui::Screen::ShowBadError("Can't get path to save directory");
		return "";
	}
#else
# error Unsupported system
#endif
}
Example #12
0
CString CAddonUpdaterApp::GetTempPath(BOOL bCreate)
{
	CString strPath;
	::GetTempPath(MAX_PATH, strPath.GetBuffer(MAX_PATH));
	strPath.ReleaseBuffer();
	strPath.Append(_T("AddonUpdater\\"));
	if (bCreate)
		SHCreateDirectoryEx(NULL, strPath, NULL);
	return strPath;
}
Example #13
0
static void GetIniPath(void)
{
	TCHAR	me[MAX_PATH];
	
	HRESULT hResult = SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA|CSIDL_FLAG_CREATE, NULL, SHGFP_TYPE_CURRENT, me);
	PathAppend(me, _T("TTSwTask"));
	SHCreateDirectoryEx(NULL, me, NULL);
	PathAppend(me, _T("TTSwTask.ini"));
	g_IniPath = CopyString(me);
}
Example #14
0
inline bool EnsureDirExists(const wchar_t* fullDirPath)
{
	HWND hwnd = NULL;
	const SECURITY_ATTRIBUTES *psa = NULL;
	TString dir = fullDirPath;
	int retval = SHCreateDirectoryEx(hwnd, dir.GetAsChar(), psa);
	if (retval == ERROR_SUCCESS || retval == ERROR_FILE_EXISTS || retval == ERROR_ALREADY_EXISTS) return true;

	return false;
}
Example #15
0
void StatTracker::Reset( void )
{
	m_fTimePlayed						= 0;
	m_fBuildPhaseTime					= 0;
	m_fSurvivalTime						= 0;
	m_fDistanceWalked					= 0;
	m_fBloodSpilled						= 0;
	m_uGrenadesThrown					= 0;
	m_uTotalShotsFired					= 0;
	m_uMachineGunBullets				= 0;
	m_uShotgunShells					= 0;
	m_uRPGRounds						= 0;
	m_uHatTrickShots					= 0;
	m_uWallsPlaced						= 0;
	m_uWallsPickedUp					= 0;
	m_uWindowsPlaced					= 0;
	m_uWindowsPickedUp					= 0;
	m_uTowersBought						= 0;
	m_uTowersSold						= 0;
	m_uTrapsBought						= 0;
	m_uTrapsSold						= 0;
	m_uMoneySpent						= 0;
	m_uTotalKills						= 0;
	m_uRoundsSurvived					= 0;
	m_uConsecutiveRoundsSurvived		= 0;

	HRESULT hr;
	ostringstream stringstream;
	char path[MAX_PATH];
	LPWSTR wszPath = NULL;
	size_t size;

	// Get the path to the app data folder
	hr = SHGetKnownFolderPath(FOLDERID_RoamingAppData, 0, 0, &wszPath);

	// Convert from LPWSTR to char[]
	wcstombs_s(&size, path, MAX_PATH, wszPath, MAX_PATH);

	// Convert char types
	if (hr == S_OK)
		stringstream << path;
	string pathtowrite = stringstream.str();

	// Add the company and game information
	pathtowrite += "\\RazorBalloon\\";

	// Create our directory
	SHCreateDirectoryEx(NULL, pathtowrite.c_str(), 0);

	// Create our save file
	pathtowrite += "stats.xml";

	Save(pathtowrite.c_str());
}
bool makeAllDirectories(const String& path)
{
    String fullPath = path;
    if (SHCreateDirectoryEx(0, fullPath.charactersWithNullTermination(), 0) != ERROR_SUCCESS) {
        DWORD error = GetLastError();
        if (error != ERROR_FILE_EXISTS && error != ERROR_ALREADY_EXISTS) {
            LOG_ERROR("Failed to create path %s", path.ascii().data());
            return false;
        }
    }
    return true;
}
Example #17
0
CString FileMgr::GetAppPathById(const CString& strId, const CString& strSub)
{
	CString strPath = GetAppPath();
	TCHAR szPath[MAX_PATH] = { 0 };
	StrCpy(szPath, strPath);
	PathAppend(szPath, strId);
	PathAppend(szPath, strSub);
	strPath = szPath;
	if (!PathFileExists(szPath))
	{
		SHCreateDirectoryEx(NULL, szPath, NULL);
	}
	return strPath;
}
Example #18
0
//=============================================================================
// 函数名称:	移动覆盖一个指定的目录
// 作者说明:	mushuai
// 修改时间:	2013-03-14
//=============================================================================
int ConvertPath(LPCTSTR srcpath,LPCTSTR targpath)
{
	int iresult = 1;
	CFindFile finder;
	if(finder.FindFile(srcpath))
	{
		CString fileName,filePath;
		do
		{
			fileName=finder.GetFileName();
			filePath = finder.GetFilePath();
			//. ..
			if (finder.IsDots())
			{
				continue;
			}
			//dir
			else if (finder.IsDirectory())
			{
				CString tTargPath = targpath;
				tTargPath +=_T("\\")+fileName;
				ConvertPath(filePath+_T("\\*"),tTargPath);
				RemoveDirectory(filePath);
			}
			else//file
			{
				CString newFilePath = targpath;
				newFilePath +=_T("\\")+fileName;					
				if (!PathFileExists(targpath))
				{
					if(ERROR_SUCCESS != SHCreateDirectoryEx(0,targpath,0))
					{
						return 0;
					}
				}
				BOOL res=MoveFileEx(filePath,newFilePath,MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING);
				if (!res)
				{
					SetFileAttributes(newFilePath,FILE_ATTRIBUTE_NORMAL);
					if (!DeleteFile(newFilePath))
					{
						MoveFileEx(filePath,newFilePath,MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING);
					}
				}
			}
		}while (finder.FindNextFile());
	}
	finder.Close();
	return iresult;
}
Example #19
0
bool CDir::MakeDir(const CString& sPath, mode_t iMode) {
#ifdef _WIN32
	if (sPath.empty())
		return false;

	CString sFixedPath = sPath;
	sFixedPath.Replace("/", "\\");

	int iResult = SHCreateDirectoryEx(0, sFixedPath.c_str(), NULL);

	return (iResult == ERROR_SUCCESS || iResult == ERROR_FILE_EXISTS || iResult == ERROR_ALREADY_EXISTS);
#else
	CString sDir;
	VCString dirs;
	VCString::iterator it;

	// Just in case someone tries this...
	if (sPath.empty())
		return false;

	// If this is an absolute path, we need to handle this now!
	if (sPath.Left(1) == "/")
		sDir = "/";

	// For every single subpath, do...
	sPath.Split("/", dirs, false);
	for (it = dirs.begin(); it != dirs.end(); ++it) {
		// Add this to the path we already created
		sDir += *it;

		int i = mkdir(sDir.c_str(), iMode);

		if (i != 0) {
			// All errors except EEXIST are fatal
			if (errno != EEXIST)
				return false;

			// If it's EEXIST we have to make sure it's a dir
			if (!CFile::IsDir(sDir))
				return false;
		}

		sDir += "/";
	}

	// All went well
	return true;
#endif
}
BOOL directoryCreate( LPCTSTR lpstrDir)
{
	// Create it if not exists
	if (fileExists( lpstrDir))
		return TRUE;
	switch (SHCreateDirectoryEx( NULL, lpstrDir, NULL))
	{
	case ERROR_SUCCESS: // Directory create successful
	case ERROR_FILE_EXISTS: // Directory already exists
	case ERROR_ALREADY_EXISTS:
		return TRUE;
	default:
		return FALSE;
	}
}
Example #21
0
bool makePath(const char* path)
{
	char tmp[MAX_PATH];
	char* out = tmp;
	const char* in = path;
	while (*in && out - tmp < lengthOf(tmp) - 1)
	{
		*out = *in == '/' ? '\\' : *in;
		++out;
		++in;
	}
	*out = '\0';

	int error_code = SHCreateDirectoryEx(NULL, tmp, NULL);
	return error_code == ERROR_SUCCESS;
}
Example #22
0
bool dmnUtils::CreateDirHierarchy(const gtString& dirPath)
{
    bool ret = false;
#if AMDT_BUILD_TARGET == AMDT_WINDOWS_OS
    int rc = SHCreateDirectoryEx(NULL, dirPath.asCharArray(), NULL);
    ret = (0 == rc);
#elif AMDT_BUILD_TARGET == AMDT_LINUX_OS
    std::string cmd("mkdir -p ");
    cmd.append(dirPath.asASCIICharArray());
    int rc = system(cmd.c_str());
    ret = (rc != -1);
#else
#error Unknown build configuration!
#endif

    return ret;
}
Example #23
0
    bool Directory::CreateDirectories(LPCTSTR path) 
	{
		DWORD dwAttrib = ::GetFileAttributesW(path);
		if  (dwAttrib != INVALID_FILE_ATTRIBUTES && 0 != (dwAttrib & FILE_ATTRIBUTE_DIRECTORY)) return true;

		int codeResult = ERROR_SUCCESS;

		SECURITY_ATTRIBUTES sa={};

		codeResult = SHCreateDirectoryEx(NULL, path, &sa);

        bool created = false;
        if (codeResult == ERROR_SUCCESS)
            created = true;

        return created;
    }
Example #24
0
const TCHAR* GetSaveGameDirectory(HWND hWnd, const TCHAR *gameAppDirectory)
{
	//Creamos variables temporales
	TCHAR userDataPath[MAX_PATH];

	//Establecemos esta variable estática ya que la memoria debe mantenerse en todo momento
	static TCHAR m_SaveGameDirectory[MAX_PATH];
	
	//Limpiamos el contenido de m_SaveGameDirectory (con esto aseguramos que será un objeto NULL-Terminated)
	memset(m_SaveGameDirectory, 0, sizeof(m_SaveGameDirectory));

	//Obtenemos la ruta a la carpeta especial <user name>\Application Data y la almacenamos en userDataPath
	if( !SHGetSpecialFolderPath(hWnd, userDataPath, CSIDL_APPDATA, true) )
	{
		GEE_ERROR(TEXT("GetSaveGameDirectory() - No se pudo obtener la ruta a AppData"));
		return NULL;
	}

	//Copiamos la ruta especial en nuestro buffer estático
	_tcscpy_s(m_SaveGameDirectory, userDataPath);

	//Agreamos un slash seguido del nombre de folder que se nos pidió
	_tcscat_s(m_SaveGameDirectory, FOLDER_SLASH);
	_tcscat_s(m_SaveGameDirectory, gameAppDirectory);

	//Revisamos si el directorio existe
	if( GetFileAttributes(m_SaveGameDirectory) == 0xffffffff )
	{//La carpeta pedida no existe todavía
		//Creamos la carpeta
		if( SHCreateDirectoryEx(hWnd, m_SaveGameDirectory, NULL) != ERROR_SUCCESS )
		{//Si hubo algún error en la creación
			return NULL;	//Regresamos el error
		}
	}
		
	//Agregamos un último slash para asegurarnos que cualquier ruta agregada a esta no requiera hacerlo cada vez
	_tcscat_s(m_SaveGameDirectory, FOLDER_SLASH);

	//Regresamos la dirección de la variable estática (así siempre se conserva en el mismo espacio de memoria)
	return m_SaveGameDirectory;
}
Example #25
0
bool TextureControl::SaveToTexSet(string imageName, string basepath, string setName, string channel, string subset) {
	TargetTextureSet* tts = TexSetFromName(setName);
	if(!tts) 
		return false;

	if(namedImages.find(imageName) == namedImages.end())				
		return false;
	
	ilBindImage(namedImages[imageName]);

	string outputPath = FilePathForTexSet(setName, channel, subset);
	outputPath = basepath + outputPath;

	ilEnable(IL_FILE_OVERWRITE);
	bool hasAlpha = tts->SubSetHasAlpha(channel,subset);
	string format = tts->SubSetFormat(channel, subset);

	if(format == "DXT1") {
		ilEnable(IL_SQUISH_COMPRESS);
		ilSetInteger(IL_DXTC_FORMAT, IL_DXT1);
	} else if(format == "DXT5") {
		ilEnable(IL_SQUISH_COMPRESS);
		ilSetInteger(IL_DXTC_FORMAT, IL_DXT5);
	} else if(format == "RGB") {
		ilSetInteger(IL_DXTC_FORMAT, IL_DXT_NO_COMP);
		if(ilGetInteger(IL_IMAGE_FORMAT) == IL_RGBA)
			ilConvertImage(IL_RGB,ilGetInteger(IL_IMAGE_TYPE));
	} else if(format == "RGBA") {
		ilSetInteger(IL_DXTC_FORMAT, IL_DXT_NO_COMP);

	}

	size_t pos= outputPath.rfind("\\");
	if(pos != string::npos) {
		SHCreateDirectoryEx(NULL,outputPath.substr(0,pos).c_str(),NULL);
	}	
	if(!ilSaveImage((const ILstring)outputPath.c_str())) {
		return false;
	}
	return true;
}
Example #26
0
BOOL CDlgAddTask::CheckLocation(const CString &strLocation)
{
	if (strLocation.IsEmpty())
	{
		::AfxMessageBox(GetResString(IDS_LOC_CANNT_BE_EMPTY));
		return FALSE;
	}

	if (PathFileExists(strLocation))
	{
		return TRUE;
	}

	int iResult = SHCreateDirectoryEx(NULL, strLocation, NULL);
	if (ERROR_SUCCESS != iResult && ERROR_ALREADY_EXISTS != iResult)
	{
		::AfxMessageBox(GetResString(IDS_CANNT_CREATE_THIS_DIR));
		return FALSE;
	}

	return TRUE;
}
Example #27
0
BOOLEAN CreateDirectoryPath(
    _In_ PPH_STRING DirectoryPath
    )
{
    BOOLEAN success = FALSE;
    BOOLEAN directoryExists = FALSE;
    FILE_NETWORK_OPEN_INFORMATION directoryInfo;

    if (NT_SUCCESS(PhQueryFullAttributesFileWin32(DirectoryPath->Buffer, &directoryInfo)))
    {
        if (directoryInfo.FileAttributes & FILE_ATTRIBUTE_DIRECTORY)
        {
            directoryExists = TRUE;
        }
    }

    if (!directoryExists)
    {
        INT errorCode = SHCreateDirectoryEx(NULL, DirectoryPath->Buffer, NULL);

        if (errorCode == ERROR_SUCCESS)
        {
            DEBUG_MSG(L"Created Directory: %s\r\n", DirectoryPath->Buffer);
            success = TRUE;
        }
        else
        {
            DEBUG_MSG(L"SHCreateDirectoryEx Failed\r\n");
        }
    }
    else
    {
        //DEBUG_MSG(L"Directory Exists: %s\r\n", DirectoryPath->Buffer);
        success = TRUE;
    }

    return success;
}
void makePath(std::string path, bool hasFilePart = false) {

    if (path[1] != ':') {
        char arr[512];
        arr[GetCurrentDirectory(512, arr)] = 0;
        path = std::string(arr) + "\\" + path;
    }

    std::replace(path.begin(), path.end(), '/', '\\');
    if (hasFilePart) {
        path = path.substr(0, path.find_last_of('\\'));
    }

    std::cout << "Making dir" << std::endl;
    std::cout << "   " << path << std::endl;

    auto shError = SHCreateDirectoryEx(NULL, path.c_str(), NULL);
    if (shError == ERROR_SUCCESS || shError == ERROR_ALREADY_EXISTS) {
    }
    else {
        throw std::runtime_error("Error creating dir");
    }
}
Example #29
0
void ExchndlSetup()
{
# if defined(WZ_CC_MINGW)
	TCHAR miniDumpPath[PATH_MAX] = {'\0'};
	// Install the unhandled exception filter function
	prevExceptionFilter = SetUnhandledExceptionFilter(TopLevelExceptionFilter);

	// Retrieve the current version
	formattedVersionString = strdup(version_getFormattedVersionString());

	// Because of UAC on vista / win7 we use this to write our dumps to (unless we override it via OverrideRPTDirectory())
	// NOTE: CSIDL_PERSONAL =  C:\Users\user name\Documents
	if ( SUCCEEDED( SHGetFolderPathA( NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, miniDumpPath ) ))
	{
		PathAppend( miniDumpPath, TEXT( "Warzone 2100 master\\logs" ) );

		if( !PathFileExists( miniDumpPath ) )
		{
			if( ERROR_SUCCESS != SHCreateDirectoryEx( NULL, miniDumpPath, NULL ) )
			{
				_tcscpy(miniDumpPath, _T("c:\\temp"));
			}
		}
	}
	else
	{	// should never fail, but if it does, we fall back to this
		_tcscpy(miniDumpPath, _T("c:\\temp"));
	}

	_tcscat(szLogFileName, _T("Warzone2100.RPT"));
	_tcscat(miniDumpPath, _T("\\"));
	_tcscat(miniDumpPath,szLogFileName);
	_tcscpy(szLogFileName, miniDumpPath);

	atexit(ExchndlShutdown);
#endif
}
Example #30
0
	//! Obtain the path of the configuration directory or file
	//!
	//! @param configFilePath - Buffer of size MAX_PATH to return path in.
	//! @param filename - Configuration file name to append to configuration directory path.\n
	//!                   If NULL then the configuration directory (with trailing \) is returned.
	//!
	//! @return error code - BDM_RC_OK => success \n
	//!                    - BDM_RC_FAIL => failure
	//!
	//! @note The configuration directory will be created if it doesn't aleady exist.
	//!
	static int getApplicationDirectoryPath(const char **_configFilePath,
	                                       const char *filename) {
	   static char configFilePath[MAX_PATH];

	   memset(configFilePath, '\0', MAX_PATH);
	   *_configFilePath = configFilePath;
	   if (filename == NULL)
	      filename = "\\";

	   // Obtain local app folder (create if needed)
	   if (SHGetFolderPath(NULL,
	                       CSIDL_APPDATA|CSIDL_FLAG_CREATE,
	                       NULL,
	                       0,
	                       configFilePath) != S_OK)
	      return BDM_RC_FAIL;

	   // Append application directory name
	   if (strlen(configFilePath)+sizeof(CONFIG_WITH_SLASHES) >= MAX_PATH)
	      return BDM_RC_FAIL;

	   strcat(configFilePath, CONFIG_WITH_SLASHES);

	   // Check if folder exists or can be created
	   if ((GetFileAttributes(configFilePath) == INVALID_FILE_ATTRIBUTES) &&
	       (SHCreateDirectoryEx( NULL, configFilePath, NULL ) != S_OK))
	      return BDM_RC_FAIL;

	   // Append filename if non-NULL
	   if (strlen(configFilePath)+strlen(filename) >= MAX_PATH)
	      return BDM_RC_FAIL;

	   strcat(configFilePath, filename);

	   print("getApplicationDirectoryPath()=\'%s\'\n", configFilePath );
	   return BDM_RC_OK;
	}