Skip to content

Commit 02e5ac9

Browse files
Add APFS drive format
Ran into the same problem that was fixed in PR#32 on linux with mac. Added apfs to the list and my "Maximum data size limit reached for DAT:" problem was resolved like theirs.
1 parent 8ad54dd commit 02e5ac9

File tree

1 file changed

+25
-23
lines changed
  • xivModdingFramework/SqPack/FileTypes

1 file changed

+25
-23
lines changed

xivModdingFramework/SqPack/FileTypes/Dat.cs

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
// xivModdingFramework
22
// Copyright © 2018 Rafael Gonzalez - All Rights Reserved
3-
//
3+
//
44
// This program is free software: you can redistribute it and/or modify
55
// it under the terms of the GNU General Public License as published by
66
// the Free Software Foundation, either version 3 of the License, or
77
// (at your option) any later version.
8-
//
8+
//
99
// This program is distributed in the hope that it will be useful,
1010
// but WITHOUT ANY WARRANTY; without even the implied warranty of
1111
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212
// GNU General Public License for more details.
13-
//
13+
//
1414
// You should have received a copy of the GNU General Public License
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

@@ -42,7 +42,7 @@
4242
namespace xivModdingFramework.SqPack.FileTypes
4343
{
4444
/// <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
4646
/// </summary>
4747
public class Dat
4848
{
@@ -107,6 +107,8 @@ private static long GetMaximumFileSize(string drive)
107107
return 34359738368;
108108
case "ReiserFS":
109109
return 34359738368;
110+
case "apfs":
111+
return 34359738368;
110112
default:
111113
// Unknown HDD Format, default to the basic limit.
112114
return 2000000000;
@@ -220,7 +222,7 @@ private async Task<bool> IsOriginalDat(XivDataFile dataFile, int datNum, bool al
220222

221223
var unmoddedList = await GetUnmoddedDatList(dataFile, alreadyLocked);
222224
var datPath = $"{dataFile.GetDataFileName()}{DatExtension}{datNum}";
223-
225+
224226
for(int i = 0; i < unmoddedList.Count; i++)
225227
{
226228
unmoddedList[i] = Path.GetFileName(unmoddedList[i]);
@@ -350,7 +352,7 @@ await Task.Run(async () =>
350352
}
351353

352354
/// <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.
354356
/// </summary>
355357
/// <returns>byte array containing the header.</returns>
356358
internal static byte[] MakeSqPackHeader()
@@ -458,8 +460,8 @@ public async Task<byte[]> GetType2Data(string internalPath, bool forceOriginal,
458460
}
459461

460462
// 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+
463465
var offset = index.Get8xDataOffset(internalPath);
464466

465467
if (offset == 0)
@@ -715,7 +717,7 @@ public async Task<byte[]> CreateType2Data(byte[] dataToCreate)
715717
}
716718

717719
// 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.
719721
var folder = Path.GetDirectoryName(internalPath);
720722
folder = folder.Replace("\\", "/");
721723
var file = Path.GetFileName(internalPath);
@@ -931,7 +933,7 @@ public async Task<XivTex> GetType4Data(string internalPath, bool forceOriginal)
931933
}
932934

933935
// 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.
935937

936938
var folder = Path.GetDirectoryName(internalPath);
937939
folder = folder.Replace("\\", "/");
@@ -1062,7 +1064,7 @@ public async Task<int> GetCompressedFileSize(long offset, XivDataFile dataFile)
10621064
var offsetFromHeaderEnd = br.ReadInt32();
10631065
var mipMapCompressedSize = br.ReadInt32();
10641066

1065-
1067+
10661068
lastOffset = offsetFromHeaderEnd;
10671069
lastSize = mipMapCompressedSize;
10681070
}
@@ -1435,7 +1437,7 @@ private async Task<int> GetFirstDatWithSpace(XivDataFile dataFile, int fileSize
14351437

14361438
// If the DAT doesn't exist at all, we can assume we need to create a new DAT.
14371439
if (fInfo == null || !fInfo.Exists) break;
1438-
1440+
14391441

14401442
var datSize = fInfo.Length;
14411443

@@ -1501,7 +1503,7 @@ public async Task<long> CopyFile(string sourcePath, string targetPath, string so
15011503

15021504
/// <summary>
15031505
/// Copies a file from a given offset to a new path in the game files.
1504-
///
1506+
///
15051507
/// If the Index File and Modlist are provided, the actions will only be wrtiten to memory,
15061508
/// and not to the live Index Files/ModList.
15071509
/// </summary>
@@ -1573,9 +1575,9 @@ public async Task<long> CopyFile(long originalOffset, XivDataFile originalDataFi
15731575

15741576

15751577
/// <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
15771579
/// the indexes. Returns the raw-index-style offset to the new data.
1578-
///
1580+
///
15791581
/// A target offset of 0 or negative will append to the end of the first data file with space.
15801582
/// </summary>
15811583
/// <param name="importData"></param>
@@ -1601,7 +1603,7 @@ public async Task<uint> WriteToDat(byte[] importData, XivDataFile dataFile, long
16011603
seekPointer = (targetOffset >> 7) << 7;
16021604

16031605
// 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
16051607
// past the end of this safe slot.
16061608
if(seekPointer % 256 != 0)
16071609
{
@@ -1705,10 +1707,10 @@ public async Task<uint> WriteToDat(byte[] importData, XivDataFile dataFile, long
17051707
/// <summary>
17061708
/// Writes a given block of data to the DAT files, updates the index to point to it for the given file path,
17071709
/// creates or updates the modlist entry for the item, and triggers metadata expansion if needed.
1708-
///
1710+
///
17091711
/// NOTE -- If the Index File and ModList are provided, the steps SAVING those entires are SKIPPED for performance.
17101712
/// It is assumed if they are provided, that the calling function will handle saving them once it is done manipulating them.
1711-
///
1713+
///
17121714
/// LUMINA - If Lumina writing is enabled, the indexes/modlist/dats will NEVER be modified by this function, making it
17131715
/// functionally a NoOp() as far as the internal TexTools system state is concerned. This means if another function
17141716
/// 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
18211823
if (!doLumina)
18221824
{
18231825
// Update the Index files.
1824-
1826+
18251827
if (doDatSave)
18261828
{
18271829
originalOffset = await _index.UpdateDataOffset(retOffset, internalFilePath, true);
@@ -1830,7 +1832,7 @@ public async Task<long> WriteModFile(byte[] fileData, string internalFilePath, s
18301832
{
18311833
originalOffset = index.SetDataOffset(internalFilePath, retOffset);
18321834
}
1833-
1835+
18341836
}
18351837

18361838
var longOriginal = ((long)originalOffset) * 8L;
@@ -1891,7 +1893,7 @@ public async Task<long> WriteModFile(byte[] fileData, string internalFilePath, s
18911893
{
18921894
await _modding.SaveModListAsync(modList);
18931895
}
1894-
1896+
18951897
// Perform metadata expansion if needed.
18961898
var ext = Path.GetExtension(internalFilePath);
18971899
if (ext == ".meta")
@@ -1937,7 +1939,7 @@ private void WriteWithLumina(byte[] data, DirectoryInfo outDirectory, string int
19371939
{
19381940
Debug.WriteLine($"[LUMINA] Export START for {internalPath}");
19391941

1940-
1942+
19411943
var extractedFile = new FileInfo(Path.Combine(outDirectory.FullName, internalPath));
19421944
extractedFile.Directory?.Create();
19431945

@@ -2020,7 +2022,7 @@ public static long OffsetCorrection(int datNum, long offset)
20202022
var ret = offset - (16 * datNum);
20212023
return ret;
20222024
}
2023-
2025+
20242026
/// <summary>
20252027
/// Computes a dictionary listing of all the open space in a given dat file (within the modded dats only).
20262028
/// </summary>

0 commit comments

Comments
 (0)