示例#1
0
        public RecursiveAddFromDirectoryWithFilterHandler(string[] cmdArgs) : base(cmdArgs)
        {
            _fileFilter = CmdParser.Value(CmdArgumentOptions.FileFilter);
            if (string.IsNullOrWhiteSpace(_fileFilter))
            {
                _fileFilter = "*.pdb";
            }

            if (!CmdParser.IsKey(CmdArgumentOptions.SymStoreArgs))
            {
                Help();
                throw new ArgumentException(
                          $"Not found {CmdArgumentOptions.SymStoreArgs} commandline argument");
            }

            var pdbSourcePath = CmdParser.Value(CmdArgumentOptions.PdbSourcePath);

            if (string.IsNullOrWhiteSpace(pdbSourcePath) || (!CmdParser.IsArgumentBefore(CmdArgumentOptions.PdbSourcePath,
                                                                                         CmdArgumentOptions.SymStoreArgs)))
            {
                Help();
                throw new ArgumentException(
                          $"{CmdArgumentOptions.PdbSourcePath} commandline argument must exist only before command line option {CmdArgumentOptions.SymStoreArgs}");
            }

            _pdbSourcePath = pdbSourcePath;
        }
        public IDisposable Lock()
        {
            var pdbRepository = CmdParser.Value(CmdArgumentOptions.PdbRepositoryPath);

            if (string.IsNullOrWhiteSpace(pdbRepository))
            {
                throw new ArgumentException($"Not found {CmdArgumentOptions.PdbRepositoryPath} commandline argument");
            }
            Directory.CreateDirectory(pdbRepository);
            var lockFile = Path.Combine(pdbRepository, "SymStoreAdapter.lock");

            while (true)
            {
                try
                {
                    var file = File.OpenWrite(lockFile);
                    return(new RAII(() =>
                    {
                        try {
                            file.Dispose();
                            File.Delete(lockFile);
                        } catch { }
                    }));
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Lock waiting with exception: " + ex);
                    Thread.Sleep(TimeSpan.FromSeconds(10));
                }
            }
        }
示例#3
0
        public override bool AutoHandled()
        {
            if (CmdParser.Value(CmdArgumentOptions.After) is string dieAfterAgeString &&
                TimeSpan.TryParse(dieAfterAgeString, out _dieAfterAge) &&
                CmdParser.Value(CmdArgumentOptions.PdbRepositoryPath) is string pdbRepositoryPath)
            {
                _pdbRepositoryPath = pdbRepositoryPath;
                return(false);
            }

            Console.Error.WriteLine($"This mode {GetType()} required {CmdArgumentOptions.After} (in format dd.HH:mm:ss) and {CmdArgumentOptions.SymStorePath} and {CmdArgumentOptions.PdbRepositoryPath} commandline arguments.");
            return(true);
        }
        public override bool AutoHandled()
        {
            if (CmdParser.Value(CmdArgumentOptions.MaxSizeInGb) is string maxSizeInGbString &&
                long.TryParse(maxSizeInGbString, out var maxSizeInGb) &&
                CmdParser.Value(CmdArgumentOptions.PdbRepositoryPath) is string pdbRepositoryPath)
            {
                _pdbRepositoryPath = pdbRepositoryPath;
                _maxSizeInBytes    = maxSizeInGb * 1024 * 1024 * 1024;
                return(false);
            }

            Console.Error.WriteLine($"This mode {GetType()} required {CmdArgumentOptions.MaxSizeInGb} and {CmdArgumentOptions.SymStorePath} and {CmdArgumentOptions.PdbRepositoryPath} commandline arguments.");
            return(true);
        }
示例#5
0
        private void CheckArguments()
        {
            var pdbRepository = CmdParser.Value(CmdArgumentOptions.PdbRepositoryPath);

            if (string.IsNullOrWhiteSpace(pdbRepository))
            {
                throw new ArgumentException($"Not found {CmdArgumentOptions.PdbRepositoryPath} commandline argument");
            }

            var symStorePath = CmdParser.Value(CmdArgumentOptions.SymStorePath);

            if (string.IsNullOrWhiteSpace(symStorePath))
            {
                throw new ArgumentException($"Not found {CmdArgumentOptions.SymStorePath} commandline argument");
            }

            if (!File.Exists(symStorePath))
            {
                throw new ArgumentException($"Not found executable path {CmdArgumentOptions.SymStorePath} in commandline argument");
            }
        }
示例#6
0
 protected string SymStoreExecutable()
 {
     return(CmdParser.Value(CmdArgumentOptions.SymStorePath) ?? @"symstore.exe");
 }