mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-13 22:34:31 +00:00
Display error messages instead of breaking into the debugger when we don't have rights to save a map in Atlas. Fixes #1941.
This was SVN commit r13818.
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
|
||||
#include "maths/MathUtil.h"
|
||||
#include "maths/NUSpline.h"
|
||||
#include "ps/CLogger.h"
|
||||
#include "ps/Loader.h"
|
||||
#include "ps/Filesystem.h"
|
||||
#include "ps/XML/XMLWriter.h"
|
||||
@@ -63,8 +64,16 @@ void CMapWriter::SaveMap(const VfsPath& pathname, CTerrain* pTerrain,
|
||||
// build necessary data
|
||||
PackMap(packer, pTerrain);
|
||||
|
||||
// write it out
|
||||
packer.Write(pathname);
|
||||
try
|
||||
{
|
||||
// write it out
|
||||
packer.Write(pathname);
|
||||
}
|
||||
catch (PSERROR_File_WriteFailed&)
|
||||
{
|
||||
LOGERROR(L"Failed to write map '%ls'", pathname.string().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
VfsPath pathnameXML = pathname.ChangeExtension(L".xml");
|
||||
WriteXML(pathnameXML, pWaterMan, pSkyMan, pLightEnv, pCamera, pCinema, pPostproc, pSimulation2);
|
||||
@@ -170,7 +179,7 @@ void CMapWriter::PackTerrain(CFilePacker& packer, CTerrain* pTerrain)
|
||||
packer.PackString(terrainTextures[i]);
|
||||
|
||||
// pack tile data
|
||||
packer.PackRaw(&tiles[0],sizeof(STileDesc)*tiles.size());
|
||||
packer.PackRaw(&tiles[0],sizeof(STileDesc)*tiles.size());
|
||||
}
|
||||
|
||||
void CMapWriter::WriteXML(const VfsPath& filename,
|
||||
@@ -444,8 +453,8 @@ void CMapWriter::WriteXML(const VfsPath& filename,
|
||||
}
|
||||
}
|
||||
}
|
||||
if (! XML_StoreVFS(g_VFS, filename))
|
||||
DEBUG_WARN_ERR(ERR::LOGIC); // failed to write map XML file
|
||||
if (!XML_StoreVFS(g_VFS, filename))
|
||||
LOGERROR(L"Failed to write map '%ls'", filename.string().c_str());
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -301,7 +301,7 @@ static inline Status Store(const OsPath& pathname, const void* data, size_t size
|
||||
int oflag = O_WRONLY;
|
||||
if(p.queueDepth != 1)
|
||||
oflag |= O_DIRECT;
|
||||
WARN_RETURN_STATUS_IF_ERR(file.Open(pathname, oflag));
|
||||
RETURN_STATUS_IF_ERR(file.Open(pathname, oflag));
|
||||
io::Operation op(file, (void*)data, size);
|
||||
|
||||
#if OS_WIN
|
||||
|
||||
@@ -132,7 +132,12 @@ public:
|
||||
{
|
||||
ScopedLock s;
|
||||
VfsDirectory* directory;
|
||||
WARN_RETURN_STATUS_IF_ERR(vfs_Lookup(pathname, &m_rootDirectory, directory, 0, VFS_LOOKUP_ADD|VFS_LOOKUP_CREATE|VFS_LOOKUP_CREATE_ALWAYS));
|
||||
Status st;
|
||||
st = vfs_Lookup(pathname, &m_rootDirectory, directory, 0, VFS_LOOKUP_ADD|VFS_LOOKUP_CREATE|VFS_LOOKUP_CREATE_ALWAYS);
|
||||
if (st == ERR::FILE_ACCESS)
|
||||
return ERR::FILE_ACCESS;
|
||||
|
||||
WARN_RETURN_STATUS_IF_ERR(st);
|
||||
|
||||
const PRealDirectory& realDirectory = directory->AssociatedDirectory();
|
||||
const OsPath name = pathname.Filename();
|
||||
@@ -163,8 +168,8 @@ public:
|
||||
s.~ScopedLock();
|
||||
return CreateFile(pathname, fileContents, size);
|
||||
}
|
||||
else
|
||||
WARN_RETURN_STATUS_IF_ERR(st);
|
||||
|
||||
WARN_RETURN_STATUS_IF_ERR(st);
|
||||
|
||||
RealDirectory realDirectory(file->Loader()->Path(), file->Priority(), directory->AssociatedDirectory()->Flags());
|
||||
RETURN_STATUS_IF_ERR(realDirectory.Store(pathname.Filename(), fileContents, size));
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "lib/external_libraries/suppress_boost_warnings.h"
|
||||
|
||||
#include "lib/sysdep/filesystem.h"
|
||||
#include "lib/file/file.h"
|
||||
#include "lib/file/vfs/vfs.h" // error codes
|
||||
#include "lib/file/vfs/vfs_tree.h"
|
||||
#include "lib/file/vfs/vfs_populate.h"
|
||||
@@ -61,6 +62,9 @@ static Status CreateDirectory(const OsPath& path)
|
||||
return INFO::OK;
|
||||
}
|
||||
|
||||
if (errno == EACCES)
|
||||
return ERR::FILE_ACCESS;
|
||||
|
||||
// unexpected failure
|
||||
debug_printf(L"wmkdir failed with errno=%d\n", errno);
|
||||
DEBUG_WARN_ERR(ERR::LOGIC);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2009 Wildfire Games.
|
||||
/* Copyright (C) 2013 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "precompiled.h"
|
||||
|
||||
#include "FileIo.h"
|
||||
#include "ps/CLogger.h"
|
||||
#include "ps/Filesystem.h"
|
||||
#include "lib/byte_order.h"
|
||||
|
||||
@@ -65,8 +66,12 @@ void CFilePacker::Write(const VfsPath& filename)
|
||||
m_writeBuffer.Overwrite(&payloadSize_le, sizeof(payloadSize_le), 0+offsetof(FileHeader, payloadSize_le));
|
||||
|
||||
// write out all data (including header)
|
||||
if(g_VFS->CreateFile(filename, m_writeBuffer.Data(), m_writeBuffer.Size()) < 0)
|
||||
const Status st = g_VFS->CreateFile(filename, m_writeBuffer.Data(), m_writeBuffer.Size());
|
||||
if (st < 0)
|
||||
{
|
||||
LOGERROR(L"Failed to write file '%ls' with status '%lld'", filename.string().c_str(), (long long)st);
|
||||
throw PSERROR_File_WriteFailed();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2011 Wildfire Games.
|
||||
/* Copyright (C) 2013 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -102,7 +102,7 @@ bool XMLWriter_File::StoreVFS(const PIVFS& vfs, const VfsPath& pathname)
|
||||
Status ret = vfs->CreateFile(pathname, data, size);
|
||||
if (ret < 0)
|
||||
{
|
||||
LOGERROR(L"Error saving XML data through VFS: %lld", (long long)ret);
|
||||
LOGERROR(L"Error saving XML data through VFS: %lld '%ls'", (long long)ret, pathname.string().c_str());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user