ExpansionDownloader.Service.DownloaderService.GenerateSaveFile C# (CSharp) Method

GenerateSaveFile() public method

Creates a filename (where the file should be saved) from info about a download.
public GenerateSaveFile ( string filename, long filesize ) : string
filename string /// The filename. ///
filesize long /// The filesize. ///
return string
        public string GenerateSaveFile(string filename, long filesize)
        {
            string path = this.GenerateTempSaveFileName(filename);

            if (!Helpers.IsExternalMediaMounted)
            {
                
                Log.Debug(Tag,"External media not mounted: {0}", path);

                throw new GenerateSaveFileError(ExpansionDownloadStatus.DeviceNotFoundError, "external media is not yet mounted");
            }

            if (File.Exists(path))
            {
                Log.Debug(Tag,"File already exists: {0}", path);

                throw new GenerateSaveFileError(
                    ExpansionDownloadStatus.FileAlreadyExists, "requested destination file already exists");
            }

            if (Helpers.GetAvailableBytes(Helpers.GetFileSystemRoot(path)) < filesize)
            {
                throw new GenerateSaveFileError(
                    ExpansionDownloadStatus.InsufficientSpaceError, "insufficient space on external storage");
            }

            return path;
        }