tModLoader v0.11.8.9
A mod to make and play Terraria mods
Terraria.ModLoader.BackupIO.Player Class Reference

Responsible for archiving player backups More...

+ Collaboration diagram for Terraria.ModLoader.BackupIO.Player:

Static Public Member Functions

static void ArchivePlayer (string path, bool isCloudSave)
 

Static Public Attributes

static readonly string PlayerBackupDir = Path.Combine(PlayerDir, "Backups")
 
static readonly string PlayerDir = Path.Combine(Main.SavePath, "Players")
 

Static Private Member Functions

static void WriteArchive (ZipFile zip, bool isCloudSave, string path)
 Write the archive. Writes the .plr and .tplr files, then writes the player directory More...
 
static void WriteCloudFiles (ZipFile zip, string path)
 Write cloud files, which will get the relevant part of the path and write map & tmap files More...
 
static void WriteLocalFiles (ZipFile zip, string path)
 Write local files, which simply writes the entire player dir More...
 

Detailed Description

Responsible for archiving player backups

Definition at line 133 of file BackupIO.cs.

Member Function Documentation

◆ ArchivePlayer()

static void Terraria.ModLoader.BackupIO.Player.ArchivePlayer ( string  path,
bool  isCloudSave 
)
static

◆ WriteArchive()

static void Terraria.ModLoader.BackupIO.Player.WriteArchive ( ZipFile  zip,
bool  isCloudSave,
string  path 
)
staticprivate

Write the archive. Writes the .plr and .tplr files, then writes the player directory

Definition at line 144 of file BackupIO.cs.

144 {
145 // Write .plr and .tplr files
146 if (FileUtilities.Exists(path, isCloudSave)) zip.AddZipEntry(path, isCloudSave);
147 path = Path.ChangeExtension(path, ".tplr");
148 if (FileUtilities.Exists(path, isCloudSave)) zip.AddZipEntry(path, isCloudSave);
149
150 // Write other files, such as tmap files to the zip
151 if (isCloudSave) WriteCloudFiles(zip, path);
152 else WriteLocalFiles(zip, path);
153 }
static void WriteLocalFiles(ZipFile zip, string path)
Write local files, which simply writes the entire player dir
Definition: BackupIO.cs:174
static void WriteCloudFiles(ZipFile zip, string path)
Write cloud files, which will get the relevant part of the path and write map & tmap files
Definition: BackupIO.cs:158

References Terraria.ModLoader.BackupIO.Player.WriteCloudFiles(), and Terraria.ModLoader.BackupIO.Player.WriteLocalFiles().

+ Here is the call graph for this function:

◆ WriteCloudFiles()

static void Terraria.ModLoader.BackupIO.Player.WriteCloudFiles ( ZipFile  zip,
string  path 
)
staticprivate

Write cloud files, which will get the relevant part of the path and write map & tmap files

Definition at line 158 of file BackupIO.cs.

158 {
159 // Path is still equal to local path
160 var name = Path.GetFileNameWithoutExtension(path);
161 path = Path.ChangeExtension(path, "");
162 path = path.Substring(0, path.Length - 1);
163 // Write map files from plr dir in cloud
164 var cloudFiles = SocialAPI.Cloud.GetFiles().Where(p => p.StartsWith(path, StringComparison.CurrentCultureIgnoreCase)
165 && (p.EndsWith(".map", StringComparison.CurrentCultureIgnoreCase) || p.EndsWith(".tmap", StringComparison.CurrentCultureIgnoreCase)));
166
167 foreach (string cloudPath in cloudFiles)
168 zip.AddEntry($"{name}/{Path.GetFileName(cloudPath)}", FileUtilities.ReadAllBytes(cloudPath, true));
169 }

Referenced by Terraria.ModLoader.BackupIO.Player.WriteArchive().

+ Here is the caller graph for this function:

◆ WriteLocalFiles()

static void Terraria.ModLoader.BackupIO.Player.WriteLocalFiles ( ZipFile  zip,
string  path 
)
staticprivate

Write local files, which simply writes the entire player dir

Definition at line 174 of file BackupIO.cs.

174 {
175 // Write map files from plr dir
176 var plrDir = Path.Combine(Path.GetDirectoryName(path), Path.GetFileNameWithoutExtension(path));
177 if (Directory.Exists(plrDir)) zip.AddZipEntry(plrDir);
178 }

Referenced by Terraria.ModLoader.BackupIO.Player.WriteArchive().

+ Here is the caller graph for this function:

Member Data Documentation

◆ PlayerBackupDir

readonly string Terraria.ModLoader.BackupIO.Player.PlayerBackupDir = Path.Combine(PlayerDir, "Backups")
static

Definition at line 136 of file BackupIO.cs.

◆ PlayerDir

readonly string Terraria.ModLoader.BackupIO.Player.PlayerDir = Path.Combine(Main.SavePath, "Players")
static

Definition at line 135 of file BackupIO.cs.