Removes FileIOEventBus
Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#ifndef AZCORE_SYSTEM_FILE_BUS_H
|
||||
#define AZCORE_SYSTEM_FILE_BUS_H
|
||||
|
||||
#include <AzCore/IO/SystemFile.h>
|
||||
#include <AzCore/EBus/EBus.h>
|
||||
#include <AzCore/std/parallel/mutex.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace IO
|
||||
{
|
||||
/**
|
||||
* Interface for handling file io events. All events are syncronized
|
||||
*/
|
||||
class FileIOEvents
|
||||
: public AZ::EBusTraits
|
||||
{
|
||||
public:
|
||||
virtual ~FileIOEvents() {}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// EBusTraits overrides
|
||||
//TODO rbbaklov or zolniery look into why a recursive lock was not needed previously
|
||||
typedef AZStd::recursive_mutex MutexType; //< make sure all file events are thread safe as they will called from many threads
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* You will either have a file (SystemFile) pointer or fileName pointer to the file name.
|
||||
* \param fileName is provided when there is NO SystemFile object (when you call static functions).
|
||||
*/
|
||||
virtual void OnError(const SystemFile* file, const char* fileName, int errorCode) = 0;
|
||||
};
|
||||
|
||||
typedef AZ::EBus<FileIOEvents> FileIOEventBus;
|
||||
}
|
||||
}
|
||||
#endif // AZCORE_SYSTEM_FILE_BUS_H
|
||||
#pragma once
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
#include <AzCore/IO/SystemFile.h>
|
||||
#include <AzCore/IO/FileIO.h>
|
||||
#include <AzCore/IO/FileIOEventBus.h>
|
||||
|
||||
#include <AzCore/PlatformIncl.h>
|
||||
#include <AzCore/std/functional.h>
|
||||
@@ -101,7 +100,6 @@ bool SystemFile::Open(const char* fileName, int mode, int platformFlags)
|
||||
{
|
||||
if (strlen(fileName) > m_fileName.max_size())
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, this, nullptr, 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -151,7 +151,6 @@ set(FILES
|
||||
IO/CompressorZStd.h
|
||||
IO/FileIO.cpp
|
||||
IO/FileIO.h
|
||||
IO/FileIOEventBus.h
|
||||
IO/FileReader.cpp
|
||||
IO/FileReader.h
|
||||
IO/IOUtils.h
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
#include <AzCore/IO/SystemFile.h>
|
||||
#include <AzCore/IO/FileIO.h>
|
||||
#include <AzCore/IO/FileIOEventBus.h>
|
||||
#include <AzCore/IO/Path/Path.h>
|
||||
#include <AzCore/Casting/numeric_cast.h>
|
||||
|
||||
@@ -87,7 +86,6 @@ bool SystemFile::PlatformOpen(int mode, int platformFlags)
|
||||
}
|
||||
else
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, this, nullptr, EINVAL);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -103,7 +101,6 @@ bool SystemFile::PlatformOpen(int mode, int platformFlags)
|
||||
{
|
||||
if (isApkFile)
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, this, nullptr, ENOSPC);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -125,7 +122,6 @@ bool SystemFile::PlatformOpen(int mode, int platformFlags)
|
||||
|
||||
if (m_handle == PlatformSpecificInvalidHandle)
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, this, nullptr, errorCode);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -168,22 +164,8 @@ namespace Platform::Internal
|
||||
entry = readdir(dir);
|
||||
}
|
||||
|
||||
int lastError = errno;
|
||||
if (lastError != 0)
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, nullptr, filter, lastError);
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
}
|
||||
else
|
||||
{
|
||||
int lastError = errno;
|
||||
if (lastError != ENOENT)
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, nullptr, filter, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FindFilesInApk(const char* filter, const SystemFile::FindFileCB& cb)
|
||||
@@ -234,10 +216,6 @@ namespace Platform
|
||||
if (handle != PlatformSpecificInvalidHandle)
|
||||
{
|
||||
off_t result = fseeko(handle, static_cast<off_t>(offset), mode);
|
||||
if (result != 0)
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, systemFile, nullptr, errno);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -248,7 +226,6 @@ namespace Platform
|
||||
off_t result = ftello(handle);
|
||||
if (result == (off_t)-1)
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, systemFile, nullptr, errno);
|
||||
return 0;
|
||||
}
|
||||
return aznumeric_cast<SizeType>(result);
|
||||
@@ -292,7 +269,6 @@ namespace Platform
|
||||
|
||||
if (bytesRead != bytesToRead && ferror(handle))
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, systemFile, nullptr, errno);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -311,7 +287,6 @@ namespace Platform
|
||||
|
||||
if (bytesWritten != bytesToWrite && ferror(handle))
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, systemFile, nullptr, errno);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -325,10 +300,7 @@ namespace Platform
|
||||
{
|
||||
if (handle != PlatformSpecificInvalidHandle)
|
||||
{
|
||||
if (fflush(handle) != 0)
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, systemFile, nullptr, errno);
|
||||
}
|
||||
fflush(handle);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -347,7 +319,6 @@ namespace Platform
|
||||
struct stat fileStat;
|
||||
if (stat(fileName, &fileStat) < 0)
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, systemFile, nullptr, 0);
|
||||
return 0;
|
||||
}
|
||||
return static_cast<SizeType>(fileStat.st_size);
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
*/
|
||||
|
||||
#include <AzCore/IO/FileIO.h>
|
||||
#include <AzCore/IO/FileIOEventBus.h>
|
||||
#include <AzCore/IO/Path/Path.h>
|
||||
#include <AzCore/IO/SystemFile.h>
|
||||
#include <AzCore/std/string/wildcard.h>
|
||||
@@ -44,21 +43,7 @@ namespace AZ::IO::Platform
|
||||
entry = readdir(dir);
|
||||
}
|
||||
|
||||
int lastError = errno;
|
||||
if (lastError != 0)
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, nullptr, filter, lastError);
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
}
|
||||
else
|
||||
{
|
||||
int lastError = errno;
|
||||
if (lastError != ENOENT)
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, nullptr, filter, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
#include <AzCore/IO/SystemFile.h>
|
||||
#include <AzCore/IO/FileIO.h>
|
||||
#include <AzCore/IO/FileIOEventBus.h>
|
||||
#include <AzCore/Casting/numeric_cast.h>
|
||||
#include <AzCore/Debug/Profiler.h>
|
||||
|
||||
@@ -130,7 +129,6 @@ namespace Platform
|
||||
int result = remove(fileName);
|
||||
if (result != 0)
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, nullptr, fileName, result);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -142,7 +140,6 @@ namespace Platform
|
||||
int result = rename(sourceFileName, targetFileName);
|
||||
if (result)
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, nullptr, sourceFileName, result);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -198,10 +195,6 @@ namespace Platform
|
||||
}
|
||||
azstrcpy(dirPath, AZ_MAX_PATH_LEN, dirName);
|
||||
bool success = CreateDirRecursive(dirPath);
|
||||
if (!success)
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, nullptr, dirName, errno);
|
||||
}
|
||||
return success;
|
||||
}
|
||||
return false;
|
||||
|
||||
+2
-21
@@ -8,7 +8,6 @@
|
||||
|
||||
#include <AzCore/IO/SystemFile.h>
|
||||
#include <AzCore/IO/FileIO.h>
|
||||
#include <AzCore/IO/FileIOEventBus.h>
|
||||
#include <AzCore/Casting/numeric_cast.h>
|
||||
|
||||
#include <AzCore/PlatformIncl.h>
|
||||
@@ -61,7 +60,6 @@ bool SystemFile::PlatformOpen(int mode, int platformFlags)
|
||||
}
|
||||
else
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, this, nullptr, 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -88,7 +86,6 @@ bool SystemFile::PlatformOpen(int mode, int platformFlags)
|
||||
|
||||
if (m_handle == PlatformSpecificInvalidHandle)
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, this, nullptr, errno);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
@@ -119,11 +116,7 @@ namespace Platform
|
||||
{
|
||||
if (handle != PlatformSpecificInvalidHandle)
|
||||
{
|
||||
int result = lseek(handle, offset, mode);
|
||||
if (result == -1)
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, systemFile, nullptr, errno);
|
||||
}
|
||||
lseek(handle, offset, mode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,10 +125,6 @@ namespace Platform
|
||||
if (handle != PlatformSpecificInvalidHandle)
|
||||
{
|
||||
off_t result = lseek(handle, 0, SEEK_CUR);
|
||||
if (result == (off_t)-1)
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, systemFile, nullptr, errno);
|
||||
}
|
||||
return aznumeric_cast<SizeType>(result);
|
||||
}
|
||||
|
||||
@@ -149,14 +138,12 @@ namespace Platform
|
||||
off_t current = lseek(handle, 0, SEEK_CUR);
|
||||
if (current == (off_t)-1)
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, systemFile, nullptr, current);
|
||||
return false;
|
||||
}
|
||||
|
||||
off_t end = lseek(handle, 0, SEEK_END);
|
||||
if (end == (off_t)-1)
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, systemFile, nullptr, end);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -191,7 +178,6 @@ namespace Platform
|
||||
ssize_t bytesRead = read(handle, buffer, byteSize);
|
||||
if (bytesRead == -1)
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, systemFile, nullptr, errno);
|
||||
return 0;
|
||||
}
|
||||
return bytesRead;
|
||||
@@ -207,7 +193,6 @@ namespace Platform
|
||||
ssize_t result = write(handle, buffer, byteSize);
|
||||
if (result == -1)
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, systemFile, nullptr, errno);
|
||||
return 0;
|
||||
}
|
||||
return result;
|
||||
@@ -221,10 +206,7 @@ namespace Platform
|
||||
if (handle != PlatformSpecificInvalidHandle)
|
||||
{
|
||||
#if AZ_TRAIT_SYSTEMFILE_FSYNC_IS_DEFINED
|
||||
if (fsync(handle) != 0)
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, systemFile, nullptr, errno);
|
||||
}
|
||||
fsync(handle);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -236,7 +218,6 @@ namespace Platform
|
||||
struct stat stat;
|
||||
if (fstat(handle, &stat) < 0)
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, systemFile, nullptr, 0);
|
||||
return 0;
|
||||
}
|
||||
return stat.st_size;
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
#include <AzCore/IO/SystemFile.h>
|
||||
#include <AzCore/IO/FileIO.h>
|
||||
#include <AzCore/IO/FileIOEventBus.h>
|
||||
#include <AzCore/Casting/numeric_cast.h>
|
||||
#include <AzCore/std/string/conversions.h>
|
||||
|
||||
@@ -142,7 +141,6 @@ bool SystemFile::PlatformOpen(int mode, int platformFlags)
|
||||
|
||||
if (m_handle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, this, nullptr, (int)GetLastError());
|
||||
return false;
|
||||
}
|
||||
else
|
||||
@@ -160,10 +158,7 @@ void SystemFile::PlatformClose()
|
||||
{
|
||||
if (m_handle != PlatformSpecificInvalidHandle)
|
||||
{
|
||||
if (!CloseHandle(m_handle))
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, this, nullptr, (int)GetLastError());
|
||||
}
|
||||
CloseHandle(m_handle);
|
||||
m_handle = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
}
|
||||
@@ -177,7 +172,7 @@ namespace Platform
|
||||
{
|
||||
using FileHandleType = AZ::IO::SystemFile::FileHandleType;
|
||||
|
||||
void Seek(FileHandleType handle, const SystemFile* systemFile, SystemFile::SeekSizeType offset, SystemFile::SeekMode mode)
|
||||
void Seek(FileHandleType handle, [[maybe_unused]] const SystemFile* systemFile, SystemFile::SeekSizeType offset, SystemFile::SeekMode mode)
|
||||
{
|
||||
if (handle != PlatformSpecificInvalidHandle)
|
||||
{
|
||||
@@ -185,14 +180,11 @@ namespace Platform
|
||||
LARGE_INTEGER distToMove;
|
||||
distToMove.QuadPart = offset;
|
||||
|
||||
if (!SetFilePointerEx(handle, distToMove, 0, dwMoveMethod))
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, systemFile, nullptr, (int)GetLastError());
|
||||
}
|
||||
SetFilePointerEx(handle, distToMove, 0, dwMoveMethod);
|
||||
}
|
||||
}
|
||||
|
||||
SystemFile::SizeType Tell(FileHandleType handle, const SystemFile* systemFile)
|
||||
SystemFile::SizeType Tell(FileHandleType handle, [[maybe_unused]] const SystemFile* systemFile)
|
||||
{
|
||||
if (handle != PlatformSpecificInvalidHandle)
|
||||
{
|
||||
@@ -202,7 +194,6 @@ namespace Platform
|
||||
LARGE_INTEGER newFilePtr;
|
||||
if (!SetFilePointerEx(handle, distToMove, &newFilePtr, FILE_CURRENT))
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, systemFile, nullptr, (int)GetLastError());
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -212,7 +203,7 @@ namespace Platform
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Eof(FileHandleType handle, const SystemFile* systemFile)
|
||||
bool Eof(FileHandleType handle, [[maybe_unused]] const SystemFile* systemFile)
|
||||
{
|
||||
if (handle != PlatformSpecificInvalidHandle)
|
||||
{
|
||||
@@ -222,14 +213,12 @@ namespace Platform
|
||||
LARGE_INTEGER currentFilePtr;
|
||||
if (!SetFilePointerEx(handle, zero, ¤tFilePtr, FILE_CURRENT))
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, systemFile, nullptr, (int)GetLastError());
|
||||
return false;
|
||||
}
|
||||
|
||||
FILE_STANDARD_INFO fileInfo;
|
||||
if (!GetFileInformationByHandleEx(handle, FileStandardInfo, &fileInfo, sizeof(fileInfo)))
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, systemFile, nullptr, (int)GetLastError());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -239,14 +228,13 @@ namespace Platform
|
||||
return false;
|
||||
}
|
||||
|
||||
AZ::u64 ModificationTime(FileHandleType handle, const SystemFile* systemFile)
|
||||
AZ::u64 ModificationTime(FileHandleType handle, [[maybe_unused]] const SystemFile* systemFile)
|
||||
{
|
||||
if (handle != PlatformSpecificInvalidHandle)
|
||||
{
|
||||
FILE_BASIC_INFO fileInfo;
|
||||
if (!GetFileInformationByHandleEx(handle, FileBasicInfo, &fileInfo, sizeof(fileInfo)))
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, systemFile, nullptr, (int)GetLastError());
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -263,7 +251,7 @@ namespace Platform
|
||||
return 0;
|
||||
}
|
||||
|
||||
SystemFile::SizeType Read(FileHandleType handle, const SystemFile* systemFile, SizeType byteSize, void* buffer)
|
||||
SystemFile::SizeType Read(FileHandleType handle, [[maybe_unused]] const SystemFile* systemFile, SizeType byteSize, void* buffer)
|
||||
{
|
||||
if (handle != PlatformSpecificInvalidHandle)
|
||||
{
|
||||
@@ -271,7 +259,6 @@ namespace Platform
|
||||
DWORD nNumberOfBytesToRead = (DWORD)byteSize;
|
||||
if (!ReadFile(handle, buffer, nNumberOfBytesToRead, &dwNumBytesRead, 0))
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, systemFile, nullptr, (int)GetLastError());
|
||||
return 0;
|
||||
}
|
||||
return static_cast<SizeType>(dwNumBytesRead);
|
||||
@@ -280,7 +267,7 @@ namespace Platform
|
||||
return 0;
|
||||
}
|
||||
|
||||
SystemFile::SizeType Write(FileHandleType handle, const SystemFile* systemFile, const void* buffer, SizeType byteSize)
|
||||
SystemFile::SizeType Write(FileHandleType handle, [[maybe_unused]] const SystemFile* systemFile, const void* buffer, SizeType byteSize)
|
||||
{
|
||||
if (handle != PlatformSpecificInvalidHandle)
|
||||
{
|
||||
@@ -288,7 +275,6 @@ namespace Platform
|
||||
DWORD nNumberOfBytesToWrite = (DWORD)byteSize;
|
||||
if (!WriteFile(handle, buffer, nNumberOfBytesToWrite, &dwNumBytesWritten, 0))
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, systemFile, nullptr, (int)GetLastError());
|
||||
return 0;
|
||||
}
|
||||
return static_cast<SizeType>(dwNumBytesWritten);
|
||||
@@ -297,25 +283,21 @@ namespace Platform
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Flush(FileHandleType handle, const SystemFile* systemFile)
|
||||
void Flush(FileHandleType handle, [[maybe_unused]] const SystemFile* systemFile)
|
||||
{
|
||||
if (handle != PlatformSpecificInvalidHandle)
|
||||
{
|
||||
if (!FlushFileBuffers(handle))
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, systemFile, nullptr, (int)GetLastError());
|
||||
}
|
||||
FlushFileBuffers(handle);
|
||||
}
|
||||
}
|
||||
|
||||
SystemFile::SizeType Length(FileHandleType handle, const SystemFile* systemFile)
|
||||
SystemFile::SizeType Length(FileHandleType handle, [[maybe_unused]] const SystemFile* systemFile)
|
||||
{
|
||||
if (handle != PlatformSpecificInvalidHandle)
|
||||
{
|
||||
LARGE_INTEGER size;
|
||||
if (!GetFileSizeEx(handle, &size))
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, systemFile, nullptr, (int)GetLastError());
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -341,7 +323,6 @@ namespace Platform
|
||||
{
|
||||
WIN32_FIND_DATA fd;
|
||||
HANDLE hFile;
|
||||
int lastError;
|
||||
|
||||
AZ::IO::FixedMaxPathWString filterW;
|
||||
AZStd::to_wstring(filterW, filter);
|
||||
@@ -367,20 +348,7 @@ namespace Platform
|
||||
cb(fileName, (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0);
|
||||
}
|
||||
|
||||
lastError = (int)GetLastError();
|
||||
FindClose(hFile);
|
||||
if (lastError != ERROR_NO_MORE_FILES)
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, nullptr, fileName, lastError);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lastError = (int)GetLastError();
|
||||
if (lastError != ERROR_FILE_NOT_FOUND)
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, nullptr, filter, lastError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -394,15 +362,11 @@ namespace Platform
|
||||
|
||||
if (handle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, nullptr, fileName, (int)GetLastError());
|
||||
return 0;
|
||||
}
|
||||
|
||||
FILE_BASIC_INFO fileInfo{};
|
||||
if (!GetFileInformationByHandleEx(handle, FileBasicInfo, &fileInfo, sizeof(fileInfo)))
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, nullptr, fileName, (int)GetLastError());
|
||||
}
|
||||
GetFileInformationByHandleEx(handle, FileBasicInfo, &fileInfo, sizeof(fileInfo));
|
||||
|
||||
CloseHandle(handle);
|
||||
|
||||
@@ -434,10 +398,6 @@ namespace Platform
|
||||
fileSize.HighPart = data.nFileSizeHigh;
|
||||
len = aznumeric_cast<SizeType>(fileSize.QuadPart);
|
||||
}
|
||||
else
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, nullptr, fileName, (int)GetLastError());
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
@@ -448,7 +408,6 @@ namespace Platform
|
||||
AZStd::to_wstring(fileNameW, fileName);
|
||||
if (DeleteFileW(fileNameW.c_str()) == 0)
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, nullptr, fileName, (int)GetLastError());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -463,7 +422,6 @@ namespace Platform
|
||||
AZStd::to_wstring(targetFileNameW, targetFileName);
|
||||
if (MoveFileExW(sourceFileNameW.c_str(), targetFileNameW.c_str(), overwrite ? MOVEFILE_REPLACE_EXISTING : 0) == 0)
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, nullptr, sourceFileName, (int)GetLastError());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -503,10 +461,6 @@ namespace Platform
|
||||
AZ::IO::FixedMaxPathWString dirNameW;
|
||||
AZStd::to_wstring(dirNameW, dirName);
|
||||
bool success = CreateDirRecursive(dirNameW);
|
||||
if (!success)
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, nullptr, dirName, (int)GetLastError());
|
||||
}
|
||||
return success;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
*/
|
||||
|
||||
#include <AzCore/IO/FileIO.h>
|
||||
#include <AzCore/IO/FileIOEventBus.h>
|
||||
#include <AzCore/IO/Path/Path.h>
|
||||
#include <AzCore/IO/SystemFile.h>
|
||||
#include <AzCore/std/string/wildcard.h>
|
||||
@@ -44,21 +43,7 @@ namespace AZ::IO::Platform
|
||||
entry = readdir(dir);
|
||||
}
|
||||
|
||||
int lastError = errno;
|
||||
if (lastError != 0)
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, nullptr, filter, lastError);
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
}
|
||||
else
|
||||
{
|
||||
int lastError = errno;
|
||||
if (lastError != ENOENT)
|
||||
{
|
||||
EBUS_EVENT(FileIOEventBus, OnError, nullptr, filter, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -409,9 +409,6 @@ namespace AzToolsFramework
|
||||
return false;
|
||||
}
|
||||
|
||||
// Surface any errors during the renames
|
||||
ScopedIOEventBusHandler renameHandler;
|
||||
|
||||
// Rename all the temp files to the actual bundle names
|
||||
for (int idx = 0; idx < bundlePathDeltaCatalogPair.size(); ++idx)
|
||||
{
|
||||
@@ -759,20 +756,5 @@ namespace AzToolsFramework
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
ScopedIOEventBusHandler::ScopedIOEventBusHandler()
|
||||
{
|
||||
BusConnect();
|
||||
}
|
||||
|
||||
ScopedIOEventBusHandler::~ScopedIOEventBusHandler()
|
||||
{
|
||||
BusDisconnect();
|
||||
}
|
||||
|
||||
void ScopedIOEventBusHandler::OnError([[maybe_unused]] const AZ::IO::SystemFile* file, [[maybe_unused]] const char* fileName, [[maybe_unused]] int errorCode)
|
||||
{
|
||||
AZ_Error("AssetBundleComponent", false, "FileIO Error for file %s (errorCode %d)", file && file->Name() ? file->Name() : fileName, errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Component/Component.h>
|
||||
#include <AzCore/IO/FileIOEventBus.h>
|
||||
#include <AzToolsFramework/AssetBundle/AssetBundleAPI.h>
|
||||
|
||||
namespace AZ
|
||||
@@ -92,14 +91,4 @@ namespace AzToolsFramework
|
||||
//! We only create the delta catalog once we are sure about what all the files that will go in it.
|
||||
bool AddCatalogAndFilesToBundle(const AZStd::vector<AZStd::string>& deltaCatalogEntries, const AZStd::vector<AZStd::string>& fileEntries, const AZStd::string& bundleFilePath, const char* assetAlias, const AzFramework::PlatformId& platformId);
|
||||
};
|
||||
|
||||
class ScopedIOEventBusHandler :
|
||||
public AZ::IO::FileIOEventBus::Handler
|
||||
{
|
||||
public:
|
||||
ScopedIOEventBusHandler();
|
||||
~ScopedIOEventBusHandler();
|
||||
|
||||
void OnError(const AZ::IO::SystemFile* file, const char* fileName, int errorCode) override;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
|
||||
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
|
||||
#include <AzCore/UserSettings/UserSettingsComponent.h>
|
||||
#include <AzCore/IO/FileIOEventBus.h>
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
|
||||
#include "BaseAssetProcessorTest.h"
|
||||
@@ -55,13 +54,11 @@ namespace AssetProcessor
|
||||
};
|
||||
|
||||
class LegacyTestAdapter : public AssetProcessorTest,
|
||||
public ::testing::WithParamInterface<std::string>,
|
||||
public AZ::IO::FileIOEventBus::Handler
|
||||
public ::testing::WithParamInterface<std::string>
|
||||
{
|
||||
void SetUp() override
|
||||
{
|
||||
AssetProcessorTest::SetUp();
|
||||
AZ::IO::FileIOEventBus::Handler::BusConnect();
|
||||
|
||||
static int numParams = 1;
|
||||
static char processName[] = {"AssetProcessorBatch"};
|
||||
@@ -91,18 +88,9 @@ namespace AssetProcessor
|
||||
void TearDown() override
|
||||
{
|
||||
m_application.reset();
|
||||
AZ::IO::FileIOEventBus::Handler::BusDisconnect();
|
||||
AssetProcessorTest::TearDown();
|
||||
}
|
||||
|
||||
void OnError(
|
||||
[[maybe_unused]] const AZ::IO::SystemFile* file,
|
||||
[[maybe_unused]] const char* fileName,
|
||||
[[maybe_unused]] int errorCode) override
|
||||
{
|
||||
AZ_Error("LegacyTestAdapter", false, "File error detected with %s with code %d", fileName, errorCode);
|
||||
}
|
||||
|
||||
AZStd::unique_ptr<UnitTestAppManager> m_application;
|
||||
|
||||
};
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <AzCore/Asset/AssetManagerBus.h>
|
||||
#include <AzCore/Component/TickBus.h>
|
||||
#include <AzCore/IO/FileIO.h>
|
||||
#include <AzCore/IO/FileIOEventBus.h>
|
||||
#include <AzCore/Script/ScriptAsset.h>
|
||||
#include <AzCore/Script/ScriptContext.h>
|
||||
#include <AzFramework/API/ApplicationAPI.h>
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include <AzCore/Asset/AssetManagerBus.h>
|
||||
#include <AzCore/Component/ComponentApplicationBus.h>
|
||||
#include <AzCore/Component/TickBus.h>
|
||||
#include <AzCore/IO/FileIOEventBus.h>
|
||||
#include <AzCore/IO/SystemFile.h>
|
||||
#include <AzCore/UserSettings/UserSettingsProvider.h>
|
||||
#include <AzFramework/Asset/AssetSystemBus.h>
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
#include <AzCore/Asset/AssetManagerBus.h>
|
||||
#include <AzCore/Component/TickBus.h>
|
||||
#include <AzCore/IO/FileIOEventBus.h>
|
||||
#include <AzFramework/Asset/AssetSystemBus.h>
|
||||
#include <AzFramework/IO/FileOperations.h>
|
||||
#include <AzToolsFramework/API/EditorAssetSystemAPI.h>
|
||||
@@ -16,37 +15,6 @@
|
||||
#include <Editor/View/Windows/Tools/UpgradeTool/FileSaver.h>
|
||||
#include <ScriptCanvas/Assets/ScriptCanvasAssetHandler.h>
|
||||
|
||||
namespace FileSaverCpp
|
||||
{
|
||||
class FileEventHandler
|
||||
: public AZ::IO::FileIOEventBus::Handler
|
||||
{
|
||||
public:
|
||||
int m_errorCode = 0;
|
||||
AZStd::string m_fileName;
|
||||
|
||||
FileEventHandler()
|
||||
{
|
||||
BusConnect();
|
||||
}
|
||||
|
||||
~FileEventHandler()
|
||||
{
|
||||
BusDisconnect();
|
||||
}
|
||||
|
||||
void OnError(const AZ::IO::SystemFile* /*file*/, const char* fileName, int errorCode) override
|
||||
{
|
||||
m_errorCode = errorCode;
|
||||
|
||||
if (fileName)
|
||||
{
|
||||
m_fileName = fileName;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
namespace ScriptCanvasEditor
|
||||
{
|
||||
namespace VersionExplorer
|
||||
@@ -63,8 +31,6 @@ namespace ScriptCanvasEditor
|
||||
, AZStd::string target
|
||||
, size_t remainingAttempts)
|
||||
{
|
||||
FileSaverCpp::FileEventHandler fileEventHandler;
|
||||
|
||||
if (remainingAttempts == 0)
|
||||
{
|
||||
AZ::SystemTickBus::QueueFunction([this, tmpFileName]()
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include "TranslationUtilities.h"
|
||||
|
||||
#include <AzCore/IO/FileIO.h>
|
||||
#include <AzCore/IO/FileIOEventBus.h>
|
||||
#include <AzFramework/API/ApplicationAPI.h>
|
||||
#include <ScriptCanvas/Core/Node.h>
|
||||
#include <ScriptCanvas/Core/Slot.h>
|
||||
@@ -71,34 +70,6 @@ namespace TranslationUtilitiesCPP
|
||||
return AZStd::string::format("%s%s_VM.%s", TranslationUtilitiesCPP::k_fileDirectoryPathLua, source.m_name.data(), extension.data());
|
||||
}
|
||||
|
||||
class FileEventHandler
|
||||
: public AZ::IO::FileIOEventBus::Handler
|
||||
{
|
||||
public:
|
||||
int m_errorCode = 0;
|
||||
AZStd::string m_fileName;
|
||||
|
||||
FileEventHandler()
|
||||
{
|
||||
BusConnect();
|
||||
}
|
||||
|
||||
~FileEventHandler()
|
||||
{
|
||||
BusDisconnect();
|
||||
}
|
||||
|
||||
void OnError(const AZ::IO::SystemFile* /*file*/, const char* fileName, int errorCode) override
|
||||
{
|
||||
m_errorCode = errorCode;
|
||||
|
||||
if (fileName)
|
||||
{
|
||||
m_fileName = fileName;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
AZ::Outcome<void, AZStd::string> SaveFile(const Grammar::Source& source, AZStd::string_view text, AZStd::string_view extension)
|
||||
{
|
||||
AZ::IO::FileIOBase* fileIO = AZ::IO::FileIOBase::GetInstance();
|
||||
@@ -111,25 +82,23 @@ namespace TranslationUtilitiesCPP
|
||||
// \todo get a (debug) file path based on the extension
|
||||
const AZStd::string filePath = TranslationUtilitiesCPP::GetDebugLuaFilePath(source, extension);
|
||||
|
||||
FileEventHandler eventHandler;
|
||||
|
||||
AZ::IO::HandleType fileHandle = AZ::IO::InvalidHandle;
|
||||
const AZ::IO::Result fileOpenResult = fileIO->Open(filePath.c_str(), AZ::IO::OpenMode::ModeWrite | AZ::IO::OpenMode::ModeText, fileHandle);
|
||||
if (fileOpenResult != AZ::IO::ResultCode::Success)
|
||||
{
|
||||
return AZ::Failure(AZStd::string::format("Failed to open file: %s, error code: %d", filePath.c_str(), eventHandler.m_errorCode));
|
||||
return AZ::Failure(AZStd::string::format("Failed to open file: %sd", filePath.c_str()));
|
||||
}
|
||||
|
||||
const AZ::IO::Result fileWriteResult = fileIO->Write(fileHandle, text.begin(), text.size());
|
||||
if (fileWriteResult != AZ::IO::ResultCode::Success)
|
||||
{
|
||||
return AZ::Failure(AZStd::string::format("Failed to write file: %s, error code: %d", filePath.c_str(), eventHandler.m_errorCode));
|
||||
return AZ::Failure(AZStd::string::format("Failed to write file: %s", filePath.c_str()));
|
||||
}
|
||||
|
||||
const AZ::IO::Result fileCloseResult = fileIO->Close(fileHandle);
|
||||
if (fileCloseResult != AZ::IO::ResultCode::Success)
|
||||
{
|
||||
return AZ::Failure(AZStd::string::format("Failed to close file: %s, error code: %d", filePath.c_str(), eventHandler.m_errorCode));
|
||||
return AZ::Failure(AZStd::string::format("Failed to close file: %s", filePath.c_str()));
|
||||
}
|
||||
|
||||
return AZ::Success();
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#include <AzCore/Component/TickBus.h>
|
||||
#include <AzCore/IO/FileIO.h>
|
||||
#include <AzCore/IO/IOUtils.h>
|
||||
#include <AzCore/IO/FileIOEventBus.h>
|
||||
#include <AzCore/UnitTest/UnitTest.h>
|
||||
#include <AzFramework/API/ApplicationAPI.h>
|
||||
#include <Editor/Framework/ScriptCanvasGraphUtilities.h>
|
||||
|
||||
Reference in New Issue
Block a user