Feature #2340 » 0088-fc_stat-Support-nullptr-buf.patch
| client/options.c | ||
|---|---|---|
|
fc_strlcpy(name_buffer, OPTION_FILE_NAME, sizeof(name_buffer));
|
||
|
#else
|
||
|
int major, minor;
|
||
|
struct stat buf;
|
||
|
name = freeciv_storage_dir();
|
||
|
if (name == NULL) {
|
||
| ... | ... | |
|
: minor >= 0); minor--) {
|
||
|
fc_snprintf(name_buffer, sizeof(name_buffer),
|
||
|
"%s" DIR_SEPARATOR NEW_OPTION_FILE_NAME, name, major, minor);
|
||
|
if (0 == fc_stat(name_buffer, &buf)) {
|
||
|
if (0 == fc_stat(name_buffer, nullptr)) {
|
||
|
if (MAJOR_NEW_OPTION_FILE_NAME != major
|
||
|
|| MINOR_NEW_OPTION_FILE_NAME != minor) {
|
||
|
log_normal(_("Didn't find '%s' option file, "
|
||
| ... | ... | |
|
minor--) {
|
||
|
fc_snprintf(name_buffer, sizeof(name_buffer),
|
||
|
"%s" DIR_SEPARATOR MID_OPTION_FILE_NAME, name, major, minor);
|
||
|
if (0 == fc_stat(name_buffer, &buf)) {
|
||
|
if (0 == fc_stat(name_buffer, nullptr)) {
|
||
|
log_normal(_("Didn't find '%s' option file, "
|
||
|
"loading from '%s' instead."),
|
||
|
get_current_option_file_name() + strlen(name) + 1,
|
||
| server/stdinhand.c | ||
|---|---|---|
|
static bool lua_command(struct connection *caller, char *arg, bool check,
|
||
|
int read_recursion)
|
||
|
{
|
||
|
struct stat statbuf;
|
||
|
const char extension[] = ".lua", *real_filename = nullptr;
|
||
|
char luafile[4096], tilde_filename[4096];
|
||
|
char *tokens[1], *luaarg = nullptr;
|
||
| ... | ... | |
|
_("Loading Freeciv script file '%s'."), real_filename);
|
||
|
if (is_reg_file_for_access(real_filename, FALSE)
|
||
|
&& !fc_stat(real_filename, &statbuf)) {
|
||
|
&& !fc_stat(real_filename, nullptr)) {
|
||
|
ret = script_server_do_file(caller, real_filename);
|
||
|
} else {
|
||
|
cmd_reply(CMD_LUA, caller, C_FAIL,
|
||
| ... | ... | |
|
_("Loading Freeciv script file '%s'."), real_filename);
|
||
|
if (is_reg_file_for_access(real_filename, FALSE)
|
||
|
&& !fc_stat(real_filename, &statbuf)) {
|
||
|
&& !fc_stat(real_filename, nullptr)) {
|
||
|
ret = script_server_unsafe_do_file(caller, real_filename);
|
||
|
} else {
|
||
|
cmd_reply(CMD_LUA, caller, C_FAIL,
|
||
| utility/registry.c | ||
|---|---|---|
|
bool allow_duplicates)
|
||
|
{
|
||
|
#ifdef FREECIV_HAVE_XML_REGISTRY
|
||
|
struct stat buf;
|
||
|
if (fc_stat(filename, &buf) == 0) {
|
||
|
if (fc_stat(filename, nullptr) == 0) {
|
||
|
xmlDoc *sec_doc;
|
||
|
sec_doc = xmlReadFile(filename, nullptr, XML_PARSE_NOERROR);
|
||
| utility/shared.c | ||
|---|---|---|
|
#endif /* DIR_SEPARATOR_IS_DEFAULT */
|
||
|
strvec_iterate(dirs, dirname) {
|
||
|
struct stat buf; /* See if we can open the file or directory */
|
||
|
astr_set(&realfile, "%s" DIR_SEPARATOR "%s", dirname, fnbuf);
|
||
|
if (fc_stat(astr_str(&realfile), &buf) == 0) {
|
||
|
if (fc_stat(astr_str(&realfile), nullptr) == 0) {
|
||
|
return astr_str(&realfile);
|
||
|
}
|
||
|
} strvec_iterate_end;
|
||
| utility/support.c | ||
|---|---|---|
|
/************************************************************************//**
|
||
|
Wrapper function for stat() with filename conversion to local
|
||
|
encoding on Windows.
|
||
|
@param filename Name of the file to check
|
||
|
@param buf Stat struct to fill. Can be nullptr
|
||
|
@return 0 on success, -1 on failure
|
||
|
****************************************************************************/
|
||
|
int fc_stat(const char *filename, struct stat *buf)
|
||
|
{
|
||
|
struct stat dummy;
|
||
|
struct stat *ptr;
|
||
|
if (buf != nullptr) {
|
||
|
ptr = buf;
|
||
|
} else {
|
||
|
ptr = &dummy;
|
||
|
}
|
||
|
#ifdef FREECIV_MSWINDOWS
|
||
|
int result;
|
||
|
char *filename_in_local_encoding =
|
||
|
internal_to_local_string_malloc(filename);
|
||
|
result = stat(filename_in_local_encoding, buf);
|
||
|
result = stat(filename_in_local_encoding, ptr);
|
||
|
free(filename_in_local_encoding);
|
||
|
return result;
|
||
|
#else /* FREECIV_MSWINDOWS */
|
||
|
return stat(filename, buf);
|
||
|
return stat(filename, ptr);
|
||
|
#endif /* FREECIV_MSWINDOWS */
|
||
|
}
|
||
- « Previous
- 1
- 2
- Next »