public static string DumpToFile(out bool success)
        {
            string fileName;

            success = DataDumper.DumpToFile(out fileName);
            return(fileName);
        }
        public static bool DumpToFile(out string fileName)
        {
            string data;
            IDictionary <string, Func <string> > dumpables = DataDumper.GetDumpables();

            Func <KeyValuePair <string, Func <string> >, string> getKey = kv => {
                try { return(kv.Value()); }
                catch (Exception e) { return("ERROR: " + e.Message); }
            };

            lock (DataDumper.MyLock) {
                data = string.Join("\r\n", dumpables
                                   .ToDictionary(kv => kv.Key, getKey)
                                   .SafeSelect(kv => kv.Key + ":\r\n" + kv.Value)
                                   );
            }

            bool success = DataDumper.DumpToLocalFile(data, out fileName);

            if (success)
            {
                // Allow admins to dump on behalf of server, also
                if (Main.netMode == 1)
                {
                    if (ModHelpersMod.Instance.Config.DebugModeDumpAlsoServer || UserHelpers.HasBasicServerPrivilege(Main.LocalPlayer))
                    {
                        PacketProtocolRequestToServer.QuickRequest <DataDumpProtocol>(-1);
                    }
                }
            }

            return(success);
        }
        ////////////////

        public static void SetDumpSource(string name, Func <string> dump)
        {
            var dumpables = DataDumper.GetDumpables();

            lock (DataDumper.MyLock) {
                dumpables[name] = dump;
            }
        }
        ////////////////

        public static bool DumpToLocalFile(string data, out string fileName)
        {
            fileName = DataDumper.GetFileName((DataDumper.Dumps++) + "");
            string relPath    = DataDumper.GetRelativePath();
            string fullFolder = Main.SavePath + Path.DirectorySeparatorChar + relPath;
            string fullPath   = fullFolder + Path.DirectorySeparatorChar + fileName;

            DataDumper.PrepareDir();
            return(FileHelpers.SaveTextFile(data, fullPath, false, false));
        }
        ////////////////

        private static void PrepareDir()
        {
            string fullDir = Main.SavePath + Path.DirectorySeparatorChar + DataDumper.GetRelativePath();

            try {
                Directory.CreateDirectory(Main.SavePath);
                Directory.CreateDirectory(Main.SavePath + Path.DirectorySeparatorChar + "Logs");
                Directory.CreateDirectory(fullDir);
            } catch (IOException e) {
                throw new IOException("Failed to prepare directory: " + fullDir, e);
            }
        }