Exemplo n.º 1
0
        private void Initialize(out string commentPrefix, out int flags)
        {
            if (Filename.EndsWith(".ini", StringComparison.OrdinalIgnoreCase) || Filename.EndsWith(".conf", StringComparison.OrdinalIgnoreCase))
            {
                commentPrefix = ";";
                flags         = 1;

                return;
            }

            if (Filename.EndsWith(".gf", StringComparison.OrdinalIgnoreCase))
            {
                commentPrefix = "//";
                flags         = 2;

                return;
            }

            if (Filename.EndsWith(".mvm", StringComparison.OrdinalIgnoreCase))
            {
                commentPrefix = null;
                flags         = 4;

                return;
            }

            throw new NotImplementedException();
        }
Exemplo n.º 2
0
    public void FindLargeFiles(List <string> AllowedExtensions, long MinSize)
    {
        foreach (string Filename in Manifest)
        {
            FileInfo FI   = new FileInfo(Filename);
            long     Size = FI.Length;

            if (Size > MinSize)
            {
                bool bAllowed = false;
                foreach (string Extension in AllowedExtensions)
                {
                    if (Filename.EndsWith(Extension, StringComparison.InvariantCultureIgnoreCase))
                    {
                        bAllowed = true;
                        break;
                    }
                }

                if (!bAllowed)
                {
                    CommandUtils.LogWarning("{0} is {1} with an unexpected extension", Filename, AnalyzeThirdPartyLibs.ToMegabytes(Size));
                }
            }
        }
    }
Exemplo n.º 3
0
        private string GenerateFullPath()
        {
            var checkedFilePath = Filepath.TrimEnd(new char['\\']) + "\\";
            var checkedFileName = Filename.EndsWith(".xml") ? Filename : Filename + ".xml";

            return(checkedFilePath + checkedFileName);
        }
Exemplo n.º 4
0
 public bool IsTGA()
 {
     if (Filename.EndsWith(".tga"))
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 5
0
 public bool IsImage()
 {
     if (ImageExts.Any(x => Filename.EndsWith(x)))
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 6
0
        public HFSFile(BinaryReader reader, bool slim = false)
        {
            if (reader.ReadInt32() != HFHeader)
            {
                throw new HFSException(HFSError.HFSFileMismatch);
            }

            ExtractVersion = reader.ReadInt16();
            BitFlag        = reader.ReadInt16();
            Contract.Assert(BitFlag == 0, "BitFlag == 0");
            CompressionMethod = (HFSCompressionMethod)reader.ReadInt16();
            Contract.Assert(CompressionMethod == HFSCompressionMethod.Store, "CompressionMethod == Store");
            ModFileTime = reader.ReadInt16();
            ModFileDate = reader.ReadInt16();
            int position;

            if (!slim)
            {
                Checksum         = reader.ReadInt32();
                CompressedSize   = reader.ReadInt32();
                DecompressedSize = reader.ReadInt32();
                var filenameLength = reader.ReadInt16();
                var extraLength    = reader.ReadInt16();
                position = (int)reader.BaseStream.Position;
                Filename = HFS.XorStringWithKey(reader.ReadBytes(filenameLength), HFSXorTruths.KeyTable, position);
                position = (int)reader.BaseStream.Position;
                Extra    = HFS.XorStringWithKey(reader.ReadBytes(extraLength), HFSXorTruths.KeyTable, position);
            }
            else
            {
                CompressedSize = DecompressedSize = (int)(reader.BaseStream.Length - reader.BaseStream.Position);
                Filename       = "unknown.bin";
            }
            position = (int)reader.BaseStream.Position;
            Data     = HFS.XorBlockWithKey(reader.ReadBytes(CompressedSize), HFSXorTruths.KeyTable, position);
            if (Filename.EndsWith(".comp"))
            {
                using (var ms = new MemoryStream(Data))
                    using (var msReader = new BinaryReader(ms))
                    {
                        ms.Position = 0;
                        var compressionHeader = msReader.ReadInt32();
                        var compressionSize   = msReader.ReadInt32();
                        if (compressionHeader == CompHeader)
                        {
                            ms.Position     += 2;
                            DecompressedSize = compressionSize;
                            Filename         = Path.GetFileNameWithoutExtension(Filename);
                            using (var zip = new DeflateStream(ms, CompressionMode.Decompress))
                            {
                                Data = new byte[compressionSize];
                                zip.Read(Data, 0, compressionSize);
                            }
                        }
                    }
            }
        }
        void FillViewers()
        {
            ((Gtk.ListStore)viewerSelector.Model).Clear();
            currentViewers.Clear();

            if (Filenames.Length == 0 || Filename.Length == 0 || System.IO.Directory.Exists(Filename))
            {
                return;
            }

            int selected = -1;
            int i        = 0;

            if (IdeApp.Services.ProjectService.IsWorkspaceItemFile(Filename) || IdeApp.Services.ProjectService.IsSolutionItemFile(Filename))
            {
                viewerSelector.AppendText(GettextCatalog.GetString("Solution Workbench"));
                currentViewers.Add(null);

                if (closeWorkspaceCheck.Visible)
                {
                    closeWorkspaceCheck.Active = true;
                }

                // Default exe/dll to AssemblyBrowser, solutions/projects to Solution Workbench.
                // HACK: Couldn't make it a generic SolutionItemFile based conditional, .csproj fits under this category also.
                if (!(Filename.EndsWith(".exe", StringComparison.OrdinalIgnoreCase) || Filename.EndsWith(".dll", StringComparison.OrdinalIgnoreCase)))
                {
                    selected = 0;
                }
                i++;
            }

            foreach (FileViewer vw in DisplayBindingService.GetFileViewers(Filename, null))
            {
                if (!vw.IsExternal)
                {
                    viewerSelector.AppendText(vw.Title);
                    currentViewers.Add(vw);

                    if (vw.CanUseAsDefault && selected == -1)
                    {
                        selected = i;
                    }

                    i++;
                }
            }

            if (selected == -1)
            {
                selected = 0;
            }

            viewerSelector.Active = selected;
            viewerLabel.Sensitive = viewerSelector.Sensitive = currentViewers.Count > 1;
        }
Exemplo n.º 8
0
        protected override void VisitResolvedElement(XElement element, MSBuildLanguageElement resolved)
        {
            foreach (var rat in resolved.Attributes)
            {
                if (rat.Required && !rat.IsAbstract)
                {
                    var xat = element.Attributes.Get(new XName(rat.Name), true);
                    if (xat == null)
                    {
                        AddError($"{element.Name.Name} must have attribute {rat.Name}", element.GetNameRegion());
                    }
                }
            }

            switch (resolved.Kind)
            {
            case MSBuildKind.Project:
                if (!Filename.EndsWith(".props", StringComparison.OrdinalIgnoreCase))
                {
                    ValidateProjectHasTarget(element);
                }
                break;

            case MSBuildKind.OnError:
                ValidateOnErrorOnlyFollowedByOnError(element);
                break;

            case MSBuildKind.Otherwise:
                ValidateOtherwiseIsLastElement(element);
                break;

            case MSBuildKind.Output:
                ValidateOutputHasPropertyOrItemName(element);
                break;

            case MSBuildKind.UsingTask:
                ValidateUsingTaskHasAssembly(element);
                break;

            case MSBuildKind.Import:
                ValidateImportOnlyHasVersionIfHasSdk(element);
                break;

            case MSBuildKind.Item:
                ValidateItemAttributes(resolved, element);
                break;

            case MSBuildKind.Task:
                ValidateTaskParameters(resolved, element);
                break;
            }

            base.VisitResolvedElement(element, resolved);
        }
Exemplo n.º 9
0
 private string GetFileEnding()
 {
     if (!Filename.Contains("."))
     {
         return("");
     }
     if (Filename.EndsWith("."))
     {
         return("");
     }
     return(this.Filename.Substring(Filename.LastIndexOf('.') + 1).ToLower());
 }
Exemplo n.º 10
0
 public void ProcessFile()
 {
     /** only input files are cyclops format right now. **/
     if (Filename.IndexOf("yclops") >= 0)
     {
         ProcessCyclopsFile();
     }
     else if (Filename.EndsWith(".txt"))
     {
         ProcessCadiaFile();
     }
 }
Exemplo n.º 11
0
    public void RenameFile(string newFilename)
    {
#if !UNITY_WEBGL
        IOUtils.SafeMove(Filename, newFilename);
        if (Filename.EndsWith(BIN_EXTENSION))
        {
            var oldBinFile = Path.ChangeExtension(Filename, CSV_EXTENSION);
            var newBinFile = Path.ChangeExtension(newFilename, CSV_EXTENSION);
            IOUtils.SafeMove(oldBinFile, newBinFile);
        }
#endif
        SetFilename(newFilename);
    }
Exemplo n.º 12
0
        public void IterationSetup()
        {
            var baseDir = Path.Combine(AppContext.BaseDirectory, "resources");
            var path    = Path.Combine(baseDir, Filename);
            var content = new ByteArrayContent(File.ReadAllBytes(path));

            content.Headers.Add("Content-Type", Filename.EndsWith(".png") ? "image/png" : Filename.EndsWith(".jpg") ? "image/jpeg" : "application/octet-stream");

            MultipartContent = new MultipartFormDataContent {
                { content, "files", Filename },
                { new StringContent("name"), "name" },
                { new StringContent("description"), "description" }
            };
        }
Exemplo n.º 13
0
        private void radListView1_SelectedItemChanged(object sender, EventArgs e)
        {
            var s = projectsList.SelectedItem.Tag as ProjectTemplate;

            if (s != null)
            {
                Type     = s.ProjectID;
                Template = s;

                if (!Filename.EndsWith(s.Extension))
                {
                    Filename += s.Extension;
                }
            }
        }
Exemplo n.º 14
0
    public FileView(string filePath)
    {
        FilePath = filePath;
        FileInfo = new FileInfo(filePath);

        Filename = Path.GetFileName(filePath);
        Size     = FileInfo.Length;
        Modified = FileInfo.LastWriteTime;

        if (Filename.EndsWith(".atlas"))
        {
            Tab = new TabFileSerialized(filePath);
        }
        else
        {
            Tab = new TabFile(filePath);
        }
    }
Exemplo n.º 15
0
 private void XLSTranslator_DragDrop(object sender, DragEventArgs e)
 {
     // 清除掉畫面
     ResetTextBox();
     string[] Files = (string[])e.Data.GetData(DataFormats.FileDrop);
     foreach (string Filename in Files)
     {
         if (Filename.EndsWith(".xls") == false)
         {
             continue;
         }
         m_listFilename.Add(Filename);
         string strFilename = Utility.GetFilename(Filename);
         this.TextBox_FilenameList.Text += strFilename;
     }
     // 做畫面上的更新
     this.Refresh();
 }
Exemplo n.º 16
0
        protected void Load()
        {
            if (Game.Instance.XNAGameWrapper.GraphicsDevice == null)
            {
                throw new NoSuitableGraphicsDeviceException("Shader needs a valid graphics device. Maybe are you creating before Scene.Start() is called?");
            }

            if (Filename.EndsWith(".fxb") || Filename.EndsWith(".fxc"))
            {
                XNAEffect = new Effect(Game.Instance.GraphicsDevice, File.ReadAllBytes(Filename))
                {
                    Name = Path.GetFileNameWithoutExtension(Filename)
                };
            }
            else
            {
                XNAEffect = Game.Instance.XNAGameWrapper.Content.Load <Effect>(Filename);
            }

            if (XNAEffect == null)
            {
                throw new System.NullReferenceException($"Shader '{Filename}' not found");
            }
        }