Exemplo n.º 1
0
        /// <summary>
        /// Cria instância de FileEntry a partir de um arquivo real
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="basePath"></param>
        public FileEntry(string fileName, string basePath)
        {
            if (File.Exists(fileName))
            {
                FileName     = Path.GetFileName(fileName);
                RealFilePath = Path.GetDirectoryName(fileName);
                if (string.IsNullOrEmpty(basePath))
                {
                    basePath = Path.GetDirectoryName(fileName);
                }

                BasePath = basePath;

                // Forçar carregamento das informações do arquivo
                var v = this.Version;
                var s = this.Size;
                var m = this.MD5;
                var t = this.FileType;
                var d = this.Description;


                if (RealFilePath.Length >= BasePath.Length)
                {
                    Folder = RealFilePath.Substring(BasePath.Length);
                }
                else
                {
                    Folder = "";
                }
            }
        }
Exemplo n.º 2
0
            public MPLABLocationsOSX()
            {
                string fname = null;

                using (var p = new RealFilePath(mplab_IDE_OSX))
                {
                    fname = p.GetPath;
                }
                if (string.IsNullOrWhiteSpace(fname))
                {
                    return;
                }
                if (!Directory.Exists(fname))
                {
                    return;
                }

                // Expected real path on MacOS is "/Applications/microchip/mplabx" which is a folder containing a "vX.YY/" subfolder.
                // It is assumed that this is *THE* installation directory which contains one subfolder named after the MPLAB X IDE version number.

                var dirs = new List <string>(Directory.EnumerateDirectories(fname, "v*", SearchOption.TopDirectoryOnly).OrderByDescending(dirname => dirname));

                if (dirs.Count < 1)
                {
                    return;
                }
                var installDir = dirs[0];

                if (!Directory.Exists(installDir))
                {
                    return;
                }
                Version      = Path.GetFileName(installDir);
                SourceFolder = Path.Combine(installDir, "packs", "Microchip");
                if (Directory.Exists(SourceFolder))
                {
                    IsValid = true;
                }
            }
Exemplo n.º 3
0
            public MPLABLocationsUX()
            {
                string fname = null;

                using (var p = new RealFilePath(mplab_IDE_UX))
                {
                    fname = p.GetPath;
                }
                if (string.IsNullOrWhiteSpace(fname))
                {
                    return;
                }

                // Expected real path on Linux is "<installdir>/vX.YY/mplab_platform/bin/mplab_ide".
                // We need to keep "vX.YY" as the version string and "<installdir>/vX.YY/packs/Microchip/" as the pathname of packs folder.
                //
                fname = Path.GetDirectoryName(fname); // remove trailing "/mplab_ide"
                if (string.IsNullOrWhiteSpace(fname))
                {
                    return;
                }
                fname = Path.GetDirectoryName(fname); // remove trailing "/bin"
                if (string.IsNullOrWhiteSpace(fname))
                {
                    return;
                }
                fname = Path.GetDirectoryName(fname); // remove trailing "/mplab_platform"
                if (string.IsNullOrWhiteSpace(fname))
                {
                    return;
                }
                Version      = Path.GetFileName(fname);
                SourceFolder = Path.Combine(fname, "packs", "Microchip");
                if (Directory.Exists(SourceFolder))
                {
                    IsValid = true;
                }
            }