Пример #1
0
        private bool forceDownloadTile(string fileName)
        {
            lock (_threadLocker)
            {
                try
                {
                    const string stringHttpMapBaseAddress = "http://meshes.thenoobbot.com/";

                    string stringHttpMap = stringHttpMapBaseAddress + Utility.GetDetourSupportedVersion() + "/";
                    var    continentDir  = fileName.Split('\\');
                    Directory.CreateDirectory(_meshPath + "\\" + continentDir[0] + "\\");

                    if (!Others.ExistFile(_meshPath + "\\" + fileName))
                    {
                        Logging.Write("Downloading \"" + fileName + "\"...");
                        if (!Others.DownloadFile(stringHttpMap + fileName.Replace("\\", "/") + ".gz",
                                                 _meshPath + "\\" + fileName + ".gz"))
                        {
                            return(false);
                        }
                        if (!GZip.Decompress(_meshPath + "\\" + fileName + ".gz"))
                        {
                            return(false);
                        }
                        if (Others.ExistFile(_meshPath + "\\" + fileName + ".gz"))
                        {
                            File.Delete(_meshPath + "\\" + fileName + ".gz");
                        }
                        if (Others.ExistFile(_meshPath + "\\" + fileName))
                        {
                            return(true);
                        }
                        return(false);
                    }

                    return(true);
                }
                catch (Exception exception)
                {
                    Logging.WriteError("forceDownloadTile(string fileName): " + exception);
                    return(false);
                }
            }
        }