win32.c
changeset 5120 e12dfc67761f
parent 5108 dc67d70b5a45
child 5167 2b9d61386688
equal deleted inserted replaced
5119:7e7fc659218a 5120:e12dfc67761f
   635 	}
   635 	}
   636 }
   636 }
   637 
   637 
   638 DIR *opendir(const char *path)
   638 DIR *opendir(const char *path)
   639 {
   639 {
   640 	char search_path[MAX_PATH];
       
   641 	DIR *d;
   640 	DIR *d;
   642 	UINT sem = SetErrorMode(SEM_FAILCRITICALERRORS); // disable 'no-disk' message box
   641 	UINT sem = SetErrorMode(SEM_FAILCRITICALERRORS); // disable 'no-disk' message box
   643 	DWORD fa = GetFileAttributes(path);
   642 	DWORD fa = GetFileAttributes(path);
   644 
   643 
   645 	if ((fa != INVALID_FILE_ATTRIBUTES) && (fa & FILE_ATTRIBUTE_DIRECTORY)) {
   644 	if ((fa != INVALID_FILE_ATTRIBUTES) && (fa & FILE_ATTRIBUTE_DIRECTORY)) {
   646 		d = dir_calloc();
   645 		d = dir_calloc();
   647 		if (d != NULL) {
   646 		if (d != NULL) {
       
   647 			char search_path[MAX_PATH];
   648 			/* build search path for FindFirstFile */
   648 			/* build search path for FindFirstFile */
   649 			snprintf(search_path, lengthof(search_path), "%s" PATHSEP "*", path);
   649 			snprintf(search_path, lengthof(search_path), "%s" PATHSEP "*", path);
   650 			d->hFind = FindFirstFile(search_path, &d->fd);
   650 			d->hFind = FindFirstFile(search_path, &d->fd);
   651 
   651 
   652 			if (d->hFind != INVALID_HANDLE_VALUE ||
   652 			if (d->hFind != INVALID_HANDLE_VALUE ||
   891 
   891 
   892 	_path.personal_dir = _path.game_data_dir = cfg = malloc(MAX_PATH);
   892 	_path.personal_dir = _path.game_data_dir = cfg = malloc(MAX_PATH);
   893 	GetCurrentDirectory(MAX_PATH - 1, cfg);
   893 	GetCurrentDirectory(MAX_PATH - 1, cfg);
   894 
   894 
   895 	cfg[0] = toupper(cfg[0]);
   895 	cfg[0] = toupper(cfg[0]);
   896 	s = strchr(cfg, 0);
   896 	s = strchr(cfg, '\0');
   897 	if (s[-1] != '\\') strcpy(s, "\\");
   897 	if (s[-1] != '\\') strcpy(s, "\\");
   898 
   898 
   899 	_path.save_dir = str_fmt("%ssave", cfg);
   899 	_path.save_dir = str_fmt("%ssave", cfg);
   900 	_path.autosave_dir = str_fmt("%s\\autosave", _path.save_dir);
   900 	_path.autosave_dir = str_fmt("%s\\autosave", _path.save_dir);
   901 	_path.scenario_dir = str_fmt("%sscenario", cfg);
   901 	_path.scenario_dir = str_fmt("%sscenario", cfg);