Skip to content

Commit

Permalink
more linux port. Some files of FileSystem part was disabled in cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
q4a committed May 19, 2018
1 parent 1dbd731 commit 4742925
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 44 deletions.
48 changes: 6 additions & 42 deletions src/xrCore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ set(SOURCES
cpuid.cpp
crc32.cpp
dump_string.cpp
file_stream_reader.cpp
FileSystem.cpp
FileSystem_borland.cpp
# file_stream_reader.cpp
# FileSystem.cpp
# FileSystem_borland.cpp
## FileSystem_posix.cpp
FMesh.cpp
FS.cpp
# FS.cpp
FTimer.cpp
LocatorAPI.cpp
LocatorAPI_auth.cpp
Expand Down Expand Up @@ -36,43 +37,6 @@ set(SOURCES
_math.cpp
_sphere.cpp
_std_extensions.cpp
# clsid.cpp
# cpuid.cpp
# crc32.cpp
# doug_lea_allocator.cpp
# dump_string.cpp
# FMesh.cpp
# FS.cpp
# FTimer.cpp
# LocatorAPI.cpp
# LocatorAPI_auth.cpp
# LocatorAPI_defs.cpp
# log.cpp
# LzHuf.cpp
# memory_allocation_stats.cpp
# memory_monitor.cpp
# memory_usage.cpp
# Model.cpp
# NET_utils.cpp
# os_clipboard.cpp
# ppmd_compressor.cpp
# stdafx.cpp
# string_concatenations.cpp
# xrCore.cpp
# ModuleLookup.cpp
# xrDebug.cpp
# xrMemory.cpp
# xrMemory_debug.cpp
# xrMemory_POOL.cpp
# xrsharedmem.cpp
# xrstring.cpp
# Xr_ini.cpp
# xr_shared.cpp
# xr_trims.cpp
# _compressed_normal.cpp
# _math.cpp
# _sphere.cpp
# _std_extensions.cpp
)

set(HEADERS
Expand Down Expand Up @@ -110,7 +74,7 @@ set(HEADERS
PPMdType.h
resource.h
stdafx.h
Stream_Reader.h
stream_reader.h
stream_reader_inline.h
string_concatenations.h
string_concatenations_inline.h
Expand Down
15 changes: 14 additions & 1 deletion src/xrCore/FS.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
#include "stdafx.h"
#pragma hdrstop

#include "fs_internal.h"
#include "FS_internal.h"

#pragma warning(push)
#pragma warning(disable : 4995)
#ifdef WINDOWS
#include <io.h>
#include <direct.h>
#include <fcntl.h>
#include <sys\stat.h>
#else
/*
#include <sys/stat.h>
long _filelength(char *f)
{
struct stat st;
stat(f, &st);
return st.st_size;
}
*/
#endif
#pragma warning(pop)

#ifdef M_BORLAND
Expand Down
4 changes: 4 additions & 0 deletions src/xrCore/FS_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
#pragma once

#include "lzhuf.h"
#ifdef WINDOWS
#include <io.h>
#include <fcntl.h>
#include <sys\stat.h>
#include <share.h>
#endif

void* FileDownload(LPCSTR fn, u32* pdwSize = NULL);
void FileCompress(const char* fn, const char* sign, void* data, u32 size);
Expand Down Expand Up @@ -46,12 +48,14 @@ class CFileWriter : public IWriter
{
fclose(hf);
// release RO attrib
#ifdef WINDOWS
DWORD dwAttr = GetFileAttributes(fName.c_str());
if ((dwAttr != u32(-1)) && (dwAttr & FILE_ATTRIBUTE_READONLY))
{
dwAttr &= ~FILE_ATTRIBUTE_READONLY;
SetFileAttributes(fName.c_str(), dwAttr);
}
#endif // Probably not needed.
}
}
// kernel
Expand Down
2 changes: 2 additions & 0 deletions src/xrCore/FileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
#include "stdafx.h"
#pragma hdrstop

#ifdef WINDOWS
#include "cderr.h"
#include "commdlg.h"
#include "vfw.h"
#endif

std::unique_ptr<EFS_Utils> xr_EFS;
//----------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions src/xrCore/FileSystem_borland.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@

#include "FileSystem.h"

#ifdef WINDOWS
#include <io.h>
#include <fcntl.h>
#include <sys\stat.h>

#include <Shlobj.h>
#endif

//#pragma comment(lib, "OSDialogB.lib")

Expand Down
2 changes: 2 additions & 0 deletions src/xrCore/LocatorAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@

#pragma warning(push)
#pragma warning(disable : 4995)
#ifdef WINDOWS
#include <direct.h>
#include <fcntl.h>
#include <sys/stat.h>
#endif
#pragma warning(pop)

#include "FS_internal.h"
Expand Down
File renamed without changes.
9 changes: 8 additions & 1 deletion src/xrCore/stream_reader_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ IC CStreamReader& CStreamReader::operator=(const CStreamReader&)
}

IC const HANDLE& CStreamReader::file_mapping_handle() const { return (m_file_mapping_handle); }
IC void CStreamReader::unmap() { UnmapViewOfFile(m_current_map_view_of_file); }
IC void CStreamReader::unmap()
{
#ifdef WINDOWS
UnmapViewOfFile(m_current_map_view_of_file);
#else
#warning TODO: Port CStreamReader::unmap()
#endif
}
IC void CStreamReader::remap(const u32& new_offset)
{
unmap();
Expand Down

0 comments on commit 4742925

Please sign in to comment.