• R/O
  • SSH
  • HTTPS

eirfs: Commit


Commit MetaInfo

Revisión167 (tree)
Tiempo2022-04-10 20:26:03
Autorquiret

Log Message

- adjusted the FileSystem library to the new Eir SDK revision

Cambiar Resumen

Diferencia incremental

--- FileSystem/include/CFileSystemInterface.h (revision 166)
+++ FileSystem/include/CFileSystemInterface.h (revision 167)
@@ -1800,7 +1800,7 @@
18001800 }
18011801
18021802 // Helpful things.
1803- template <typename charType>
1803+ template <eir::CharacterType charType>
18041804 AINLINE const charType* FileGetReadModeBinary( void )
18051805 {
18061806 if constexpr ( std::is_same <charType, char>::value )
@@ -1813,7 +1813,7 @@
18131813 }
18141814 else if constexpr ( std::is_same <charType, char8_t>::value )
18151815 {
1816- return (const char8_t*)u8"rb";
1816+ return u8"rb";
18171817 }
18181818 else if constexpr ( std::is_same <charType, char16_t>::value )
18191819 {
@@ -1823,16 +1823,9 @@
18231823 {
18241824 return U"rb";
18251825 }
1826- else
1827- {
1828-#ifdef _MSC_VER
1829- // Only available for MSBUILD because it is a smarter compiler.
1830- static_assert( false, "invalid character type for read-mode-binary string fetch" );
1831-#endif //_MSC_VER
1832- }
18331826 }
18341827
1835- template <typename charType>
1828+ template <eir::CharacterType charType>
18361829 AINLINE const charType* FileGetWriteModeBinary( void )
18371830 {
18381831 if constexpr ( std::is_same <charType, char>::value )
@@ -1845,7 +1838,7 @@
18451838 }
18461839 else if constexpr ( std::is_same <charType, char8_t>::value )
18471840 {
1848- return (const char8_t*)u8"wb";
1841+ return u8"wb";
18491842 }
18501843 else if constexpr ( std::is_same <charType, char32_t>::value )
18511844 {
@@ -1855,16 +1848,9 @@
18551848 {
18561849 return u"wb";
18571850 }
1858- else
1859- {
1860-#ifdef _MSC_VER
1861- // Only available to MSBUILD because it is a smarter compiler.
1862- static_assert( false, "invalid character type in write-mode-binary string fetch" );
1863-#endif
1864- }
18651851 }
18661852
1867- template <typename charType>
1853+ template <eir::CharacterType charType>
18681854 inline const charType* GetAnyWildcardSelector( void )
18691855 {
18701856 if constexpr ( std::is_same <charType, char>::value )
@@ -1877,7 +1863,7 @@
18771863 }
18781864 else if constexpr ( std::is_same <charType, char8_t>::value )
18791865 {
1880- return (const char8_t*)u8"*";
1866+ return u8"*";
18811867 }
18821868 else if constexpr ( std::is_same <charType, char16_t>::value )
18831869 {
@@ -1887,19 +1873,12 @@
18871873 {
18881874 return U"*";
18891875 }
1890- else
1891- {
1892- // Only available to MSVC because it is a smarter compiler.
1893-#ifdef _MSC_VER
1894- static_assert( false, "invalid character type" );
1895-#endif //_MSC_VER
1896- }
18971876 }
18981877
1899- template <typename charType>
1878+ template <eir::CharacterType charType>
19001879 inline const charType* GetDirectorySeparator( bool trueForwardFalseBackward )
19011880 {
1902- if constexpr ( std::is_same <charType, char>::value )
1881+ if constexpr ( std::same_as <charType, char> )
19031882 {
19041883 if ( trueForwardFalseBackward )
19051884 {
@@ -1910,7 +1889,7 @@
19101889 return "\\";
19111890 }
19121891 }
1913- else if constexpr ( std::is_same <charType, wchar_t>::value )
1892+ else if constexpr ( std::same_as <charType, wchar_t> )
19141893 {
19151894 if ( trueForwardFalseBackward )
19161895 {
@@ -1921,27 +1900,42 @@
19211900 return L"\\";
19221901 }
19231902 }
1924- else if constexpr ( std::is_same <charType, char8_t>::value )
1903+ else if constexpr ( std::same_as <charType, char8_t> )
19251904 {
19261905 if ( trueForwardFalseBackward )
19271906 {
1928- return (const char8_t*)u8"/";
1907+ return u8"/";
19291908 }
19301909 else
19311910 {
1932- return (const char8_t*)u8"\\";
1911+ return u8"\\";
19331912 }
19341913 }
1935- else
1914+ else if constexpr ( std::same_as <charType, char16_t> )
19361915 {
1937- // Only available to MSVC because it is a smarter compiler.
1938-#ifdef _MSC_VER
1939- static_assert( false, "invalid character type" );
1940-#endif //_MSC_VER
1916+ if ( trueForwardFalseBackward )
1917+ {
1918+ return u"/";
1919+ }
1920+ else
1921+ {
1922+ return u"\\";
1923+ }
19411924 }
1925+ else if constexpr ( std::same_as <charType, char32_t> )
1926+ {
1927+ if ( trueForwardFalseBackward )
1928+ {
1929+ return U"/";
1930+ }
1931+ else
1932+ {
1933+ return U"\\";
1934+ }
1935+ }
19421936 }
19431937
1944- template <typename charType>
1938+ template <eir::CharacterType charType>
19451939 AINLINE bool IsDirectorySeparator( charType cp )
19461940 {
19471941 if constexpr ( std::is_same <charType, char>::value )
@@ -1958,28 +1952,21 @@
19581952 }
19591953 else if constexpr ( std::is_same <charType, char8_t>::value )
19601954 {
1961- return ( cp == (char8_t)u8'/' || cp == (char8_t)u8'\\' );
1955+ return ( cp == u8'/' || cp == u8'\\' );
19621956 }
19631957 else if constexpr ( std::is_same <charType, char32_t>::value )
19641958 {
19651959 return ( cp == U'/' || cp == U'\\' );
19661960 }
1967- else
1968- {
1969- // Only available to MSVC because it is a smarter compiler.
1970-#ifdef _MSC_VER
1971- static_assert( false, "invalid character type" );
1972-#endif //_MSC_VER
1973- }
19741961 }
19751962
1976- template <typename charType>
1963+ template <eir::CharacterType charType>
19771964 inline const charType* GetDefaultDirectorySeparator( void )
19781965 {
19791966 return GetDirectorySeparator <charType> ( true );
19801967 }
19811968
1982- template <typename charType>
1969+ template <eir::CharacterType charType>
19831970 inline charType GetDotCharacter( void )
19841971 {
19851972 if constexpr ( std::is_same <charType, char>::value )
@@ -1992,7 +1979,7 @@
19921979 }
19931980 else if constexpr ( std::is_same <charType, char8_t>::value )
19941981 {
1995- return (char8_t)'.';
1982+ return u8'.';
19961983 }
19971984 else if constexpr ( std::is_same <charType, char16_t>::value )
19981985 {
@@ -2002,13 +1989,6 @@
20021989 {
20031990 return U'.';
20041991 }
2005- else
2006- {
2007- // Only available to MSVC because it is a smarter compiler.
2008-#ifdef _MSC_VER
2009- static_assert( false, "invalid character type in GetDotCharacter" );
2010-#endif //_MSC_VER
2011- }
20121992 }
20131993
20141994 // Copies from one translator to another using optimizations.
--- FileSystem/src/CFileSystem.cpp (revision 166)
+++ FileSystem/src/CFileSystem.cpp (revision 167)
@@ -177,21 +177,6 @@
177177 #endif //_WIN32
178178 }
179179
180-struct fs_constructor
181-{
182- const fs_construction_params& params;
183-
184- inline fs_constructor( const fs_construction_params& params ) : params( params )
185- {
186- return;
187- }
188-
189- inline CFileSystemNative* Construct( void *mem ) const
190- {
191- return new (mem) CFileSystemNative( this->params );
192- }
193-};
194-
195180 // Creators of the CFileSystem instance.
196181 // Those are the entry points to this (static) library.
197182 CFileSystem* CFileSystem::Create( const fs_construction_params& params )
@@ -215,10 +200,8 @@
215200 try
216201 {
217202 // Create our CFileSystem instance!
218- fs_constructor constructor( params );
203+ CFileSystemNative *instance = _fileSysFactory.ConstructArgs( _memAlloc, params );
219204
220- CFileSystemNative *instance = _fileSysFactory.ConstructTemplate( _memAlloc, constructor );
221-
222205 if ( instance )
223206 {
224207 // Get the application current directory and store it in "fileRoot" global.
--- FileSystem/src/CFileSystem.img.cpp (revision 166)
+++ FileSystem/src/CFileSystem.img.cpp (revision 167)
@@ -33,28 +33,29 @@
3333 return;
3434 }
3535
36-template <typename charType>
36+template <eir::CharacterType charType>
3737 inline const charType* GetReadWriteMode( bool isNew )
3838 {
39- if constexpr ( std::is_same <charType, char>::value )
39+ if constexpr ( std::same_as <charType, char> )
4040 {
4141 return ( isNew ? "wb" : "rb+" );
4242 }
43- else if constexpr ( std::is_same <charType, wchar_t>::value )
43+ else if constexpr ( std::same_as <charType, wchar_t> )
4444 {
4545 return ( isNew ? L"wb" : L"rb+" );
4646 }
47- else if constexpr ( std::is_same <charType, char8_t>::value )
47+ else if constexpr ( std::same_as <charType, char8_t> )
4848 {
49- return ( isNew ? (const char8_t*)"wb" : (const char8_t*)"rb+" );
49+ return ( isNew ? u8"wb" : u8"rb+" );
5050 }
51- else
51+ else if constexpr ( std::same_as <charType, char16_t> )
5252 {
53- // Only available to MSVC because it is a smarter compiler.
54-#ifdef _MSC_VER
55- static_assert( false, "invalid character type" );
56-#endif //_MSC_VER
53+ return ( isNew ? u"wb" : u"rb+" );
5754 }
55+ else if constexpr ( std::same_as <charType, char32_t> )
56+ {
57+ return ( isNew ? U"wb" : U"rb+" );
58+ }
5859 }
5960
6061 static AINLINE CIMGArchiveTranslator* _regularIMGConstructor( imgExtension *env, CFile *registryFile, CFile *contentFile, eIMGArchiveVersion version, bool isLiveMode )
@@ -167,28 +168,29 @@
167168 CIMGArchiveTranslatorHandle* imgExtension::NewArchive( CFileTranslator *srcRoot, const char8_t *srcPath, eIMGArchiveVersion version, bool isLiveMode )
168169 { return GenNewArchive( this, srcRoot, srcPath, version, isLiveMode ); }
169170
170-template <typename charType>
171+template <eir::CharacterType charType>
171172 inline const charType* GetOpenArchiveFileMode( bool writeAccess )
172173 {
173- if constexpr ( std::is_same <charType, char>::value )
174+ if constexpr ( std::same_as <charType, char> )
174175 {
175176 return ( writeAccess ? "rb+" : "rb" );
176177 }
177- else if constexpr ( std::is_same <charType, wchar_t>::value )
178+ else if constexpr ( std::same_as <charType, wchar_t> )
178179 {
179180 return ( writeAccess ? L"rb+" : L"rb" );
180181 }
181- else if constexpr ( std::is_same <charType, char8_t>::value )
182+ else if constexpr ( std::same_as <charType, char8_t> )
182183 {
183- return ( writeAccess ? (const char8_t*)"rb+" : (const char8_t*)"rb" );
184+ return ( writeAccess ? u8"rb+" : u8"rb" );
184185 }
185- else
186+ else if constexpr ( std::same_as <charType, char16_t> )
186187 {
187- // Only available for MSVC because it is a smarter compiler.
188-#ifdef _MSC_VER
189- static_assert( false, "fixme: unsupported character type for generic IMG open routine" );
190-#endif //_MSC_VER
188+ return ( writeAccess ? u"rb+" : u"rb" );
191189 }
190+ else if constexpr ( std::same_as <charType, char32_t> )
191+ {
192+ return ( writeAccess ? U"rb+" : U"rb" );
193+ }
192194 }
193195
194196 template <typename constructionHandler, typename... extraParamsType>
--- FileSystem/src/fsinternal/CFileSystem.img.translator.cpp (revision 166)
+++ FileSystem/src/fsinternal/CFileSystem.img.translator.cpp (revision 167)
@@ -911,7 +911,7 @@
911911 return m_virtualFS.BeginDirectoryListing( path, wildcard, filter_flags );
912912 }
913913
914-template <typename numberType>
914+template <std::unsigned_integral numberType>
915915 static AINLINE fsUInt_t getDataBlockCount( numberType dataSize )
916916 {
917917 return (fsUInt_t)ALIGN_SIZE( dataSize, (numberType)IMG_BLOCK_SIZE ) / (numberType)IMG_BLOCK_SIZE;
@@ -951,12 +951,15 @@
951951
952952 bool CIMGArchiveTranslator::ReallocateFileEntry( file *fileEntry, fsOffsetNumber_t fileSize )
953953 {
954+ if ( fileSize < 0 )
955+ return false;
956+
954957 // Only valid to call if the file entry is allocated already.
955958 if ( fileEntry->metaData.isAllocated == false )
956959 return false;
957960
958961 // Calculate the block count.
959- size_t newBlockCount = getDataBlockCount( fileSize );
962+ size_t newBlockCount = getDataBlockCount( (std::make_unsigned <fsOffsetNumber_t>::type)fileSize );
960963
961964 size_t oldBlockCount = fileEntry->metaData.resourceSize;
962965
@@ -1205,13 +1208,13 @@
12051208 // Query its size and calculate the block count depending on it.
12061209 fsOffsetNumber_t realFileSize = measureHandle->GetSizeNative();
12071210
1208- blockCount = getDataBlockCount( realFileSize );
1211+ blockCount = getDataBlockCount( (std::make_unsigned <fsOffsetNumber_t>::type)realFileSize );
12091212 }
12101213
12111214 theFile->metaData.resourceSize = blockCount;
12121215 }
12131216
1214- // Store any destination storage.
1217+ // Store any destination storage link.
12151218 if ( destinationHandle )
12161219 {
12171220 // We must store the file storage as what it is, a potentially compressed data link.
Show on old repository browser