Beispiel #1
0
        static void Main(string[] args)
        {
            var configuration          = new Configuration(args);
            var paths                  = new AssemblyPaths(configuration);
            var managedFilesFileCopier = new FileCopier(configuration.ManagedOutputPath);
            var staticFilesFileCopier  = new FileCopier(configuration.OutputPath);


            var assemblies        = new Assemblies(configuration, paths);
            var artifactsEmbedder = new ArtifactsEmbedder(configuration, assemblies);

            artifactsEmbedder.Perform();

            managedFilesFileCopier.Copy(assemblies.AllImportedAssemblyPaths);
            managedFilesFileCopier.Copy(assemblies.AllImportedAssemblyDebugSymbolPaths);

            staticFilesFileCopier.Copy(new[] {
                Path.Combine(paths.Sdk, "debug", "mono.js"),
                Path.Combine(paths.Sdk, "debug", "mono.wasm"),
                Path.Combine(paths.Sdk, "debug", "mono.wasm.map"),
                Path.Combine(paths.Sdk, "debug", "mono.wast")
            });

            var managedFiles = new List <string>();

            managedFiles.AddRange(assemblies.AllImportedAssemblyPaths);
            managedFiles.AddRange(assemblies.AllImportedAssemblyDebugSymbolPaths);

            var assembliesFilePath = Path.Combine(configuration.OutputPath, "assemblies.json");
            var fileList           = string.Join(",\n\t\t", managedFiles.Select(_ => $"\"{Path.GetFileName(_)}\"").ToArray());

            File.WriteAllText(assembliesFilePath, $"[\n\t\t{fileList}\n]");

            var monoConfigPath = Path.Combine(configuration.OutputPath, "mono-config.js");

            File.WriteAllText(monoConfigPath,
                              $"config = {{\n\tvfs_prefix: 'managed',\n\tdeploy_prefix: 'managed',\n\tenable_debugging: 0, \n\tfile_list: [\n\t\t{fileList}\n\t ],\n\tadd_bindings: function() {{ \n\t\tModule.mono_bindings_init ('[WebAssembly.Bindings]WebAssembly.Runtime');\n\t}}\n}}"
                              );

            var monoJsSource      = Path.Combine(paths.Sdk, "debug", "mono.js");
            var monoJsDestination = Path.Combine(configuration.OutputPath, "mono.js");
            var monoJs            = File.ReadAllText(monoJsSource);

            monoJs = monoJs.Replace("this.mono_wasm_runtime_is_ready=true;debugger", "this.mono_wasm_runtime_is_ready=true;");
            monoJs = monoJs.Replace(
                "  			this.mono_wasm_runtime_is_ready = true;\n"+
                "  			debugger;\n",
                "  			this.mono_wasm_runtime_is_ready = true;\n");

            File.WriteAllText(monoJsDestination, monoJs);
        }
Beispiel #2
0
        public int DllCopyThread(DataMover DMover)
        {
            FileCopier fc = DMover.fileCopier;

            List <string> DestPathes = DMover.DestPathes;
            Dictionary <int, List <string> > DllNames = DMover.DllNames;
            string DllDirPath = DMover.DllFolder;

            foreach (int key in DllNames.Keys)
            {
                foreach (string dllName in DllNames[key])
                {
                    string dllPath = BuildDllPath(dllName, DllDirPath, key);
                    if (dllPath != "")
                    {
                        foreach (string destPath in DestPathes)
                        {
                            string[] lparams = new string[2];
                            lparams[0] = dllPath;
                            lparams[1] = destPath + dllName;
                            fc.Copy(lparams);
                        }
                    }
                    else
                    {
                        return(-1);
                    }
                }
            }
            return(0);
        }
Beispiel #3
0
 public int DllCopy(FileCopier fc, List <string> DestPathes, Dictionary <int, List <string> > DllNames, string DllDirPath)
 {
     foreach (int key in DllNames.Keys)
     {
         foreach (string dllName in DllNames[key])
         {
             string dllPath = BuildDllPath(dllName, DllDirPath, key);
             if (dllPath != "")
             {
                 foreach (string destPath in DestPathes)
                 {
                     string[] lparams = new string[2];
                     lparams[0] = dllPath;
                     lparams[1] = destPath + "\\" + dllName;
                     fc.Copy(lparams);
                 }
             }
             else
             {
                 MessageBox.Show("Unable to find " + dllName);
                 return(-1);
             }
         }
     }
     return(0);
 }
Beispiel #4
0
        public void TestCopier()
        {
            IFileCopier pfc = new FileCopier();

            pfc.Copy(SRC_PATH, DST_PATH, true);
            Assert.IsTrue(File.Exists(DST_PATH));
            Assert.IsTrue(FileComparer.Compare(SRC_PATH, DST_PATH));
        }
Beispiel #5
0
 private void Init(string fileName)
 {
     if (nonPersistent)
     {
         var tempFile = TemporaryFilesManager.Instance.GetTemporaryFile();
         FileCopier.Copy(fileName, tempFile, true);
         fileName = tempFile;
     }
     stream = new SerializableStreamView(new FileStream(fileName, FileMode.OpenOrCreate), size, 0xFF);
     size2n = (byte)Misc.Logarithm2(size);
     buffer = new byte[DesiredBufferSize];
 }
 private void Init(string fileName)
 {
     if (nonPersistent)
     {
         var tempFile = TemporaryFilesManager.Instance.GetTemporaryFile();
         FileCopier.Copy(fileName, tempFile, true);
         fileName = tempFile;
     }
     stream = new SerializableFileStreamWrapper(fileName);
     CheckUnderlyingFile();
     size2n = (byte)Misc.Logarithm2(size);
     buffer = new byte[DesiredBufferSize];
 }
Beispiel #7
0
        public static string GetTAPHelper()
        {
            var extensionsAssemblyPath = TemporaryFilesManager.Instance.GetTemporaryFile();
            var generatedFileName      = TemporaryFilesManager.Instance.GetTemporaryFile();
            var dirName = Path.GetDirectoryName(generatedFileName);
            var filName = Path.GetFileName(generatedFileName);

            // Copy Extensions.dll to temp
            FileCopier.Copy(Assembly.GetExecutingAssembly().CodeBase.Substring(7), extensionsAssemblyPath, true);

            // Generate binary
            GenerateTAPHelper(dirName, filName, extensionsAssemblyPath);

            return(generatedFileName);
        }
        public static Stream Create(string imageFile, long?size = null, bool persistent = false)
        {
            if (string.IsNullOrEmpty(imageFile))
            {
                throw new ConstructionException("No image file provided.");
            }

            if (!persistent)
            {
                var tempFileName = TemporaryFilesManager.Instance.GetTemporaryFile();
                FileCopier.Copy(imageFile, tempFileName, true);
                imageFile = tempFileName;
            }

            return(new SerializableStreamView(new FileStream(imageFile, FileMode.OpenOrCreate), size));
        }
Beispiel #9
0
        private void Touch()
        {
            if (file != null)
            {
                return;
            }
            if (!persistent)
            {
                var tempFileName = TemporaryFilesManager.Instance.GetTemporaryFile();
                FileCopier.Copy(underlyingFile, tempFileName, true);
                underlyingFile = tempFileName;
            }
            var size = blockSize * (long)numberOfBlocks;

            file = new SerializableStreamView(new FileStream(underlyingFile, FileMode.OpenOrCreate), size);
        }
Beispiel #10
0
        private void Touch()
        {
            if (file != null)
            {
                return;
            }
            if (!persistent)
            {
                var tempFileName = TemporaryFilesManager.Instance.GetTemporaryFile();
                FileCopier.Copy(underlyingFile, tempFileName, true);
                underlyingFile = tempFileName;
            }
            file = new SerializableFileStreamWrapper(underlyingFile);
            var size = blockSize * (long)numberOfBlocks;

            // punch a hole if it is needed
            if (file.Stream.Length < size)
            {
                file.Stream.Seek(size - 1, SeekOrigin.Begin);
                file.Stream.WriteByte(0);
            }
        }
Beispiel #11
0
        public SDCard(string imageFile, long?cardSize, bool persistent)
        {
            if (String.IsNullOrEmpty(imageFile))
            {
                throw new ConstructionException("No card image file provided.");
            }
            else
            {
                if (!persistent)
                {
                    var tempFileName = TemporaryFilesManager.Instance.GetTemporaryFile();
                    FileCopier.Copy(imageFile, tempFileName, true);
                    imageFile = tempFileName;
                }
                file = new SerializableFileStreamWrapper(imageFile);
            }

            CardSize = cardSize ?? file.Stream.Length;

            var cardIdentificationBytes = new byte[] { 0x01, 0x00, 0x00, 0x00,       // 1b always one + 7b CRC (ignored) + 12b manufacturing date + 4b reserved
                                                       0x00, 0x00, 0x00, 0x00,       // 32b product serial number + 8b product revision
                                                       0x45, 0x44, 0x43, 0x42, 0x41, // Product name, 5 character string. "ABCDE" (backwards)
                                                       0x00, 0x00, 0x00              // 16b application ID + 8b manufacturer ID
            };

            cardIdentification    = new uint[4];
            cardIdentification[0] = BitConverter.ToUInt32(cardIdentificationBytes, 0);
            cardIdentification[1] = BitConverter.ToUInt32(cardIdentificationBytes, 4);
            cardIdentification[2] = BitConverter.ToUInt32(cardIdentificationBytes, 8);
            cardIdentification[3] = BitConverter.ToUInt32(cardIdentificationBytes, 12);

            cardSpecificData = new uint[4];
            uint deviceSize = (uint)(CardSize / 0x80000 - 1);

            cardSpecificData[0] = 0x0a4040af;
            cardSpecificData[1] = 0x3b377f80 | ((deviceSize & 0xffff) << 16);
            cardSpecificData[2] = 0x5b590000 | ((deviceSize >> 16) & 0x3f);
            cardSpecificData[3] = 0x400e0032;
        }
Beispiel #12
0
        private void BackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker  worker = (BackgroundWorker)sender;
            PlaylistWorkQueue queue  = new PlaylistWorkQueue();
            int WorkOrder            = 1;

            tbl.ClearLog();
            worker.ReportProgress(0, rm.GetString("Starting up..."));
            tsCurrentProcess.Text = rm.GetString("Starting up...");

            if (Directory.Exists(ProgramSettings.OutputFolder) &&
                File.Exists(ProgramSettings.RekordboxXMLFile))
            {
                worker.ReportProgress(0, $"{ rm.GetString("Processing") } { ProgramSettings.RekordboxXMLFile }");

                // On first run, the Playlist Helper is empty
                if (PlaylistHelper == null)
                {
                    PlaylistHelper = new PlaylistHelper(ProgramSettings.OutputFolder
                                                        , ProgramSettings.MusicFolder
                                                        , new DJ_PLAYLISTS(ProgramSettings.RekordboxXMLFile));
                }
                // On the next runs, the XML file may have changed
                else if (PlaylistHelper.Playlists.RekordboxXMLFullPath != ProgramSettings.RekordboxXMLFile)
                {
                    PlaylistHelper.Playlists = new DJ_PLAYLISTS(ProgramSettings.RekordboxXMLFile);
                }

                worker.ReportProgress(0, $"{ PlaylistHelper.TrackCount } { rm.GetString("track(s) loaded!") }");
                worker.ReportProgress(0, $"{ PlaylistHelper.PlaylistCount } { rm.GetString("Playlists loaded!") }");

                if (radPlaylists.Checked)
                {
                    // First we prepare the work queue
                    if (chkOrphans.Checked)
                    {
                        queue.AddWork(PlaylistOptions.Orphans, rm.GetString(PlaylistHelper.PROCESS_TITLE_ORPHANS), WorkOrder++);
                    }
                    if (chkDuplicates.Checked)
                    {
                        queue.AddWork(PlaylistOptions.Duplicates, rm.GetString(PlaylistHelper.PROCESS_TITLE_DUPLICATES), WorkOrder++);
                    }
                    if (chkMissing.Checked)
                    {
                        queue.AddWork(PlaylistOptions.Missing, rm.GetString(PlaylistHelper.PROCESS_TITLE_MISSING), WorkOrder++);
                    }
                    if (chkUntagged.Checked)
                    {
                        queue.AddWork(PlaylistOptions.Untagged, rm.GetString(PlaylistHelper.PROCESS_TITLE_UNTAGGED), WorkOrder++);
                    }
                    if (chkUnanalyzed.Checked)
                    {
                        queue.AddWork(PlaylistOptions.Unanalyzed, rm.GetString(PlaylistHelper.PROCESS_TITLE_UNANALYZED), WorkOrder++);
                    }
                    if (chkUnreferenced.Checked)
                    {
                        queue.AddWork(PlaylistOptions.None, rm.GetString(PlaylistHelper.PROCESS_TITLE_UNREFERENCED), WorkOrder++);
                        queue.AddWork(PlaylistOptions.Unreferenced, $"{ rm.GetString("Checking files stored in") } { ProgramSettings.MusicFolder }, { rm.GetString("this may take a while...") }", WorkOrder);
                    }

                    foreach (PlaylistWork pw in queue.Queue)
                    {
                        if (!worker.CancellationPending)
                        {
                            tsCurrentProcess.Text = pw.Title;
                            worker.ReportProgress((pw.Order * 100) / WorkOrder, pw.Title);
                            pw.DoWork(PlaylistHelper);
                        }
                        else
                        {
                            e.Cancel = true;
                            return;
                        }
                    }
                }

                else if (radStats.Checked)
                {
                    worker.ReportProgress(0, $"{rm.GetString("Calculating music library files size")}...");
                    worker.ReportProgress(100, rm.GetString("Total size:") + string.Format(new FileSizeFormatProvider(), " {0:fs}", PlaylistHelper.Playlists.Size));
                }
                else if (radBackupMusic.Checked)
                {
                    DialogResult dialogResult =
                        Messages.YesNoCancelMessage(rm.GetString("You're about to copy")
                                                    + string.Format(new FileSizeFormatProvider(), " {0:fs}. ", PlaylistHelper.Playlists.Size)
                                                    + rm.GetString("This could take a long time. Would you like to overwrite the existing files ?"));
                    bool overwrite = false;
                    switch (dialogResult)
                    {
                    case DialogResult.Yes:
                        overwrite = true;
                        break;

                    case DialogResult.No:
                        overwrite = false;
                        break;

                    case DialogResult.Cancel:
                        e.Cancel = true;
                        return;
                    }
                    worker.ReportProgress(0, $"{ rm.GetString("Starting music files copy from") } { ProgramSettings.MusicFolder } to { ProgramSettings.OutputFolder }...");
                    FileCopier fc = new FileCopier(ProgramSettings.MusicFolder, ProgramSettings.OutputFolder);

                    int count       = 1;
                    int total       = PlaylistHelper.TrackCount;
                    int errorsCount = 0;

                    foreach (string file in PlaylistHelper.CollectionMusicFiles())
                    {
                        if (!worker.CancellationPending)
                        {
                            if (fc.Copy(file, overwrite))
                            {
                                worker.ReportProgress((count++ *100) / total);
                            }
                            else
                            {
                                worker.ReportProgress((count++ *100) / total, $"{ rm.GetString("Error:") } { rm.GetString("impossible to copy") } { file }. { rm.GetString("File not found") }. ");
                                errorsCount++;
                            }
                            tsCurrentProcess.Text = $"{ count } / { total } { rm.GetString("music files processed") }";
                        }
                        else
                        {
                            e.Cancel = true;
                            return;
                        }
                    }
                    if (errorsCount > 0)
                    {
                        worker.ReportProgress(100, $"{ rm.GetString("Error:") } { errorsCount } { rm.GetString("file(s) could not be copied") }.");
                    }
                }
                worker.ReportProgress(100, rm.GetString("Finished!"));
            }
            else
            {
                string msg = $"{ rm.GetString("Impossible to start processing:") } { ProgramSettings.RekordboxXMLFile } { rm.GetString("could not be found.") }";
                worker.ReportProgress(0, msg);
                Messages.ErrorMessage(msg);
            }
        }