Forked from AnomalousUnderdog/DldUtil_DumpFilenames.cs
Created
August 25, 2014 20:44
-
-
Save Novack/67395aad09e409541f9d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEditor; | |
using System.Collections; | |
using System.IO; | |
namespace DldUtil | |
{ | |
public class DumpFilenames | |
{ | |
#if UNITY_EDITOR | |
[MenuItem("Window/Dump filenames of assets")] | |
public static void Dump() | |
{ | |
string dumpFilename = EditorUtility.SaveFilePanel( | |
"Save dump to", | |
"", | |
"FileDump", "txt"); | |
string folder = Application.dataPath; | |
Debug.Log("Dumping from: " + folder); | |
bool canceled = false; | |
System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(dumpFilename)); | |
System.IO.StreamWriter write = System.IO.File.CreateText(dumpFilename); | |
foreach (string file in TraverseDirectory.Do(folder)) | |
{ | |
canceled = EditorUtility.DisplayCancelableProgressBar("Dumping from " + folder, file, 0.5f); | |
if (canceled) | |
{ | |
write.Write("\tCanceled by user\n"); | |
Debug.Log("Dumping canceled by user"); | |
break; | |
} | |
string fileRelativePath = file.Replace(folder, ""); | |
long sizeInBytes = GetFileSizeInBytes(file); | |
write.Write(fileRelativePath + "\t" + sizeInBytes + "\n"); | |
} | |
Debug.Log("Dumping complete"); | |
write.Close(); | |
EditorUtility.ClearProgressBar(); | |
} | |
#endif | |
static long GetFileSizeInBytes(string filename) | |
{ | |
FileInfo fi = new FileInfo(filename); | |
return fi.Length; | |
} | |
} | |
} // namespace DldUtil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment