1
1
// xivModdingFramework
2
2
// Copyright © 2018 Rafael Gonzalez - All Rights Reserved
3
- //
3
+ //
4
4
// This program is free software: you can redistribute it and/or modify
5
5
// it under the terms of the GNU General Public License as published by
6
6
// the Free Software Foundation, either version 3 of the License, or
7
7
// (at your option) any later version.
8
- //
8
+ //
9
9
// This program is distributed in the hope that it will be useful,
10
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
12
// GNU General Public License for more details.
13
- //
13
+ //
14
14
// You should have received a copy of the GNU General Public License
15
15
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
42
42
namespace xivModdingFramework . SqPack . FileTypes
43
43
{
44
44
/// <summary>
45
- /// This class contains the methods that deal with the .dat file type
45
+ /// This class contains the methods that deal with the .dat file type
46
46
/// </summary>
47
47
public class Dat
48
48
{
@@ -107,6 +107,8 @@ private static long GetMaximumFileSize(string drive)
107
107
return 34359738368 ;
108
108
case "ReiserFS" :
109
109
return 34359738368 ;
110
+ case "apfs" :
111
+ return 34359738368 ;
110
112
default :
111
113
// Unknown HDD Format, default to the basic limit.
112
114
return 2000000000 ;
@@ -220,7 +222,7 @@ private async Task<bool> IsOriginalDat(XivDataFile dataFile, int datNum, bool al
220
222
221
223
var unmoddedList = await GetUnmoddedDatList ( dataFile , alreadyLocked ) ;
222
224
var datPath = $ "{ dataFile . GetDataFileName ( ) } { DatExtension } { datNum } ";
223
-
225
+
224
226
for ( int i = 0 ; i < unmoddedList . Count ; i ++ )
225
227
{
226
228
unmoddedList [ i ] = Path . GetFileName ( unmoddedList [ i ] ) ;
@@ -350,7 +352,7 @@ await Task.Run(async () =>
350
352
}
351
353
352
354
/// <summary>
353
- /// Makes the header for the SqPack portion of the dat file.
355
+ /// Makes the header for the SqPack portion of the dat file.
354
356
/// </summary>
355
357
/// <returns>byte array containing the header.</returns>
356
358
internal static byte [ ] MakeSqPackHeader ( )
@@ -458,8 +460,8 @@ public async Task<byte[]> GetType2Data(string internalPath, bool forceOriginal,
458
460
}
459
461
460
462
// If it doesn't exist in the modlist(the item is not modded) or force original is false,
461
- // grab the data directly from them index file.
462
-
463
+ // grab the data directly from them index file.
464
+
463
465
var offset = index . Get8xDataOffset ( internalPath ) ;
464
466
465
467
if ( offset == 0 )
@@ -715,7 +717,7 @@ public async Task<byte[]> CreateType2Data(byte[] dataToCreate)
715
717
}
716
718
717
719
// If it doesn't exist in the modlist(the item is not modded) or force original is false,
718
- // grab the data directly from them index file.
720
+ // grab the data directly from them index file.
719
721
var folder = Path . GetDirectoryName ( internalPath ) ;
720
722
folder = folder . Replace ( "\\ " , "/" ) ;
721
723
var file = Path . GetFileName ( internalPath ) ;
@@ -931,7 +933,7 @@ public async Task<XivTex> GetType4Data(string internalPath, bool forceOriginal)
931
933
}
932
934
933
935
// If it doesn't exist in the modlist(the item is not modded) or force original is false,
934
- // grab the data directly from them index file.
936
+ // grab the data directly from them index file.
935
937
936
938
var folder = Path . GetDirectoryName ( internalPath ) ;
937
939
folder = folder . Replace ( "\\ " , "/" ) ;
@@ -1062,7 +1064,7 @@ public async Task<int> GetCompressedFileSize(long offset, XivDataFile dataFile)
1062
1064
var offsetFromHeaderEnd = br . ReadInt32 ( ) ;
1063
1065
var mipMapCompressedSize = br . ReadInt32 ( ) ;
1064
1066
1065
-
1067
+
1066
1068
lastOffset = offsetFromHeaderEnd ;
1067
1069
lastSize = mipMapCompressedSize ;
1068
1070
}
@@ -1435,7 +1437,7 @@ private async Task<int> GetFirstDatWithSpace(XivDataFile dataFile, int fileSize
1435
1437
1436
1438
// If the DAT doesn't exist at all, we can assume we need to create a new DAT.
1437
1439
if ( fInfo == null || ! fInfo . Exists ) break ;
1438
-
1440
+
1439
1441
1440
1442
var datSize = fInfo . Length ;
1441
1443
@@ -1501,7 +1503,7 @@ public async Task<long> CopyFile(string sourcePath, string targetPath, string so
1501
1503
1502
1504
/// <summary>
1503
1505
/// Copies a file from a given offset to a new path in the game files.
1504
- ///
1506
+ ///
1505
1507
/// If the Index File and Modlist are provided, the actions will only be wrtiten to memory,
1506
1508
/// and not to the live Index Files/ModList.
1507
1509
/// </summary>
@@ -1573,9 +1575,9 @@ public async Task<long> CopyFile(long originalOffset, XivDataFile originalDataFi
1573
1575
1574
1576
1575
1577
/// <summary>
1576
- /// Writes a new block of data to the given data file, without changing
1578
+ /// Writes a new block of data to the given data file, without changing
1577
1579
/// the indexes. Returns the raw-index-style offset to the new data.
1578
- ///
1580
+ ///
1579
1581
/// A target offset of 0 or negative will append to the end of the first data file with space.
1580
1582
/// </summary>
1581
1583
/// <param name="importData"></param>
@@ -1601,7 +1603,7 @@ public async Task<uint> WriteToDat(byte[] importData, XivDataFile dataFile, long
1601
1603
seekPointer = ( targetOffset >> 7 ) << 7 ;
1602
1604
1603
1605
// If the space we're told to write to would require modification,
1604
- // don't allow writing to it, because we might potentially write
1606
+ // don't allow writing to it, because we might potentially write
1605
1607
// past the end of this safe slot.
1606
1608
if ( seekPointer % 256 != 0 )
1607
1609
{
@@ -1705,10 +1707,10 @@ public async Task<uint> WriteToDat(byte[] importData, XivDataFile dataFile, long
1705
1707
/// <summary>
1706
1708
/// Writes a given block of data to the DAT files, updates the index to point to it for the given file path,
1707
1709
/// creates or updates the modlist entry for the item, and triggers metadata expansion if needed.
1708
- ///
1710
+ ///
1709
1711
/// NOTE -- If the Index File and ModList are provided, the steps SAVING those entires are SKIPPED for performance.
1710
1712
/// It is assumed if they are provided, that the calling function will handle saving them once it is done manipulating them.
1711
- ///
1713
+ ///
1712
1714
/// LUMINA - If Lumina writing is enabled, the indexes/modlist/dats will NEVER be modified by this function, making it
1713
1715
/// functionally a NoOp() as far as the internal TexTools system state is concerned. This means if another function
1714
1716
/// relies upon the DATs/Indexes/Modlist to be altered coming out of this function, the calling function needs to
@@ -1821,7 +1823,7 @@ public async Task<long> WriteModFile(byte[] fileData, string internalFilePath, s
1821
1823
if ( ! doLumina )
1822
1824
{
1823
1825
// Update the Index files.
1824
-
1826
+
1825
1827
if ( doDatSave )
1826
1828
{
1827
1829
originalOffset = await _index . UpdateDataOffset ( retOffset , internalFilePath , true ) ;
@@ -1830,7 +1832,7 @@ public async Task<long> WriteModFile(byte[] fileData, string internalFilePath, s
1830
1832
{
1831
1833
originalOffset = index . SetDataOffset ( internalFilePath , retOffset ) ;
1832
1834
}
1833
-
1835
+
1834
1836
}
1835
1837
1836
1838
var longOriginal = ( ( long ) originalOffset ) * 8L ;
@@ -1891,7 +1893,7 @@ public async Task<long> WriteModFile(byte[] fileData, string internalFilePath, s
1891
1893
{
1892
1894
await _modding . SaveModListAsync ( modList ) ;
1893
1895
}
1894
-
1896
+
1895
1897
// Perform metadata expansion if needed.
1896
1898
var ext = Path . GetExtension ( internalFilePath ) ;
1897
1899
if ( ext == ".meta" )
@@ -1937,7 +1939,7 @@ private void WriteWithLumina(byte[] data, DirectoryInfo outDirectory, string int
1937
1939
{
1938
1940
Debug . WriteLine ( $ "[LUMINA] Export START for { internalPath } ") ;
1939
1941
1940
-
1942
+
1941
1943
var extractedFile = new FileInfo ( Path . Combine ( outDirectory . FullName , internalPath ) ) ;
1942
1944
extractedFile . Directory ? . Create ( ) ;
1943
1945
@@ -2020,7 +2022,7 @@ public static long OffsetCorrection(int datNum, long offset)
2020
2022
var ret = offset - ( 16 * datNum ) ;
2021
2023
return ret ;
2022
2024
}
2023
-
2025
+
2024
2026
/// <summary>
2025
2027
/// Computes a dictionary listing of all the open space in a given dat file (within the modded dats only).
2026
2028
/// </summary>
0 commit comments