mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-31 05:40:04 +00:00 
			
		
		
		
	android + common: fix warnings
This commit is contained in:
		
							parent
							
								
									8eb89c260d
								
							
						
					
					
						commit
						946a32d793
					
				
					 3 changed files with 29 additions and 44 deletions
				
			
		|  | @ -102,12 +102,11 @@ static void StripTailDirSlashes(std::string& fname) { | |||
| } | ||||
| 
 | ||||
| bool Exists(const std::string& filename) { | ||||
|     struct stat file_info; | ||||
| 
 | ||||
|     std::string copy(filename); | ||||
|     StripTailDirSlashes(copy); | ||||
| 
 | ||||
| #ifdef _WIN32 | ||||
|     struct stat file_info; | ||||
|     // Windows needs a slash to identify a driver root
 | ||||
|     if (copy.size() != 0 && copy.back() == ':') | ||||
|         copy += DIR_SEP_CHR; | ||||
|  | @ -116,6 +115,7 @@ bool Exists(const std::string& filename) { | |||
| #elif ANDROID | ||||
|     int result = AndroidStorage::FileExists(filename) ? 0 : -1; | ||||
| #else | ||||
|     struct stat file_info; | ||||
|     int result = stat(copy.c_str(), &file_info); | ||||
| #endif | ||||
| 
 | ||||
|  | @ -699,7 +699,7 @@ static const std::string& GetHomeDirectory() { | |||
|  * @return The directory path | ||||
|  * @sa http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
 | ||||
|  */ | ||||
| static const std::string GetUserDirectory(const std::string& envvar) { | ||||
| [[maybe_unused]] static const std::string GetUserDirectory(const std::string& envvar) { | ||||
|     const char* directory = getenv(envvar.c_str()); | ||||
| 
 | ||||
|     std::string user_dir; | ||||
|  |  | |||
|  | @ -16,19 +16,33 @@ | |||
| // Call directly after the command or use the error num.
 | ||||
| // This function might change the error code.
 | ||||
| std::string GetLastErrorMsg() { | ||||
|     constexpr std::size_t buff_size = 255; | ||||
|     char err_str[buff_size]; | ||||
|     std::size_t msg_len; | ||||
| 
 | ||||
| #ifdef _WIN32 | ||||
|     msg_len = | ||||
|         FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, nullptr, GetLastError(), | ||||
|                        MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), err_str, buff_size, nullptr); | ||||
|     LPSTR err_str; | ||||
| 
 | ||||
|     DWORD res = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | | ||||
|                                    FORMAT_MESSAGE_IGNORE_INSERTS, | ||||
|                                nullptr, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), | ||||
|                                reinterpret_cast<LPSTR>(&err_str), 1, nullptr); | ||||
|     if (!res) { | ||||
|         return "(FormatMessageA failed to format error)"; | ||||
|     } | ||||
|     std::string ret(err_str); | ||||
|     LocalFree(err_str); | ||||
|     return ret; | ||||
| #else | ||||
|     char err_str[255]; | ||||
| #if (defined(__GLIBC__) || __ANDROID_API__ >= 23) &&                                               \ | ||||
|     (_GNU_SOURCE || (_POSIX_C_SOURCE < 200112L && _XOPEN_SOURCE < 600)) | ||||
|     // Thread safe (GNU-specific)
 | ||||
|     const char* str = strerror_r(errno, err_str, sizeof(err_str)); | ||||
|     return std::string(str); | ||||
| #else | ||||
|     // Thread safe (XSI-compliant)
 | ||||
|     strerror_r(errno, err_str, buff_size); | ||||
|     msg_len = strnlen(err_str, buff_size); | ||||
| #endif | ||||
| 
 | ||||
|     return std::string(err_str, msg_len); | ||||
|     int second_err = strerror_r(errno, err_str, sizeof(err_str)); | ||||
|     if (second_err != 0) { | ||||
|         return "(strerror_r failed to format error)"; | ||||
|     } | ||||
|     return std::string(err_str); | ||||
| #endif // GLIBC etc.
 | ||||
| #endif // _WIN32
 | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue