Exemplo n.º 1
0
        private static List<string> GetFilesInPriFile(FileInfo priFileInfo, FilesToList ftl)
        {
            StreamReader sr;
            List<string> fileList = new List<string>();

            try
            {
                if (!priFileInfo.Exists)
                    return null;

                sr = new StreamReader(priFileInfo.FullName);
            }
            catch (System.Exception e)
            {
                Messages.DisplayWarningMessage(e);
                return null;
            }

            switch(ftl)
            {
                case FilesToList.FL_CppFiles:
                    ParseTag(sr, "SOURCES", fileList); break;
                case FilesToList.FL_HFiles:
                    ParseTag(sr, "HEADERS", fileList); break;
                case FilesToList.FL_UiFiles:
                    ParseTag(sr, "FORMS", fileList); break;
            }

            // the filelist should contain the entire path since we can select
            // any .pri file..
            List<string> ret = new List<string>();
            try
            {
                ret = ConvertFilesToFullPath(ret, priFileInfo.DirectoryName);
            }
            catch (System.Exception e)
            {
                Messages.DisplayErrorMessage(SR.GetString("ExportProject_ErrorParsingPriFile", e.Message),
                    SR.GetString("ExportProject_CheckFileAndSyntax"));
                return null;
            }

            sr.Close();
            return ret;
        }
Exemplo n.º 2
0
        public static List<string> GetProjectFiles(EnvDTE.Project pro, FilesToList filter)
        {
            List<string> fileList = new List<string>();

            VCProject vcpro;
            try
            {
                vcpro = (VCProject)pro.Object;
            }
            catch(System.Exception e)
            {
                Messages.DisplayErrorMessage(e);
                return null;
            }

            string configurationName = pro.ConfigurationManager.ActiveConfiguration.ConfigurationName;

            foreach(VCFile vcfile in (IVCCollection)vcpro.Files)
            {
            #if (VS2012 || VS2013)
                if (vcfile.ItemName.EndsWith(".vcxproj.filters"))
                    continue;
            #endif
                bool excluded = false;
                IVCCollection fileConfigurations = (IVCCollection)vcfile.FileConfigurations;
                foreach (VCFileConfiguration config in fileConfigurations)
                {
                    if (config.ExcludedFromBuild && config.MatchName(configurationName, false))
                    {
                        excluded = true;
                        break;
                    }
                }

                if (excluded)
                    continue;

                // can be in any filter
                if ((IsTranslationFile(vcfile)) &&
                    (filter == FilesToList.FL_Translation))
                    fileList.Add(ChangePathFormat(vcfile.RelativePath));

                // can also be in any filter
                if ((IsWinRCFile(vcfile)) &&
                    (filter == FilesToList.FL_WinResource))
                    fileList.Add(ChangePathFormat(vcfile.RelativePath));

                if (IsGenerated(vcfile))
                {
                    if (filter == FilesToList.FL_Generated)
                        fileList.Add(ChangePathFormat(vcfile.RelativePath));
                    continue;
                }

                if (IsResource(vcfile))
                {
                    if (filter == FilesToList.FL_Resources)
                        fileList.Add(ChangePathFormat(vcfile.RelativePath));
                    continue;
                }

                switch (filter)
                {
                    case FilesToList.FL_UiFiles: // form files
                        if (vcfile.Extension.ToLower() == ".ui")
                            fileList.Add(ChangePathFormat(vcfile.RelativePath));
                        break;
                    case FilesToList.FL_HFiles:
                        if (HelperFunctions.HasHeaderFileExtension(vcfile.Name))
                            fileList.Add(ChangePathFormat(vcfile.RelativePath));
                        break;
                    case FilesToList.FL_CppFiles:
                        if (HelperFunctions.HasSourceFileExtension(vcfile.Name))
                            fileList.Add(ChangePathFormat(vcfile.RelativePath));
                        break;
                }
            }

            return fileList;
        }