Beispiel #1
0
		/// <summary>The constructor</summary>
		/// <param name="base">the base configuration file</param>
		/// <param name="cfgLocation">the location of the configuration file on the file system
		/// 	</param>
		/// <param name="fs">
		/// the file system abstraction which will be necessary to perform
		/// certain file system operations.
		/// </param>
		public FileBasedConfig(Config @base, FilePath cfgLocation, FS fs) : base(@base)
		{
			configFile = cfgLocation;
			this.fs = fs;
			this.snapshot = FileSnapshot.DIRTY;
			this.hash = ObjectId.ZeroId;
		}
Beispiel #2
0
		/// <summary>Create a new lock for a pack file.</summary>
		/// <remarks>Create a new lock for a pack file.</remarks>
		/// <param name="packFile">location of the <code>pack-*.pack</code> file.</param>
		/// <param name="fs">the filesystem abstraction used by the repository.</param>
		public PackLock(FilePath packFile, FS fs)
		{
			FilePath p = packFile.GetParentFile();
			string n = packFile.GetName();
			keepFile = new FilePath(p, Sharpen.Runtime.Substring(n, 0, n.Length - 5) + ".keep"
				);
			this.fs = fs;
		}
        public void SetPrintBeginExport(UC_Print ucPrint, FS.ADIM.OA.BLL.Busi.Process.B_Finance cEntity)
        {
            switch (ucPrint.FileName)
            {
                case "公司报告":
                case "公司请示":
                    ucPrint.ExportData.Add(cEntity.MainSend); //<col>主送:|inner</col>
                    ucPrint.ExportData.Add(cEntity.Number); //<col>编码:|inner</col>
                    ucPrint.ExportData.Add(cEntity.CopySend); //<col>抄送:|inner</col>
                    ucPrint.ExportData.Add(cEntity.Department); //<col>编制处室:|inner</col>
                    ucPrint.ExportData.Add(cEntity.Drafter); //<col>编写:|inner</col>
                    ucPrint.ExportData.Add(cEntity.DeptPrincipal); //<col>审定:|inner</col>
                    ucPrint.ExportData.Add(ucPrint.CheckDateTime(cEntity.ConfirmDate.ToShortDateString())); //<col>日期:|inner</col>
                    ucPrint.ExportData.Add(cEntity.DocumentTitle); //<col>主题:|inner</col>
                    //string tmp = SysString.HtmlToTextCode(cEntity.Content);
                    string tmp = cEntity.Content;//renjinquan+

                    if (!string.IsNullOrEmpty(tmp))
                    {
                        ucPrint.ExportData.Add(tmp);
                    }
                    else
                    {
                        ucPrint.ExportData.Add("");
                    }
                    //ucPrint.ExportData.Add(cEntity.Content); //<col>正文|shift</col>
                    //string sLeaderOpinion = cEntity.LeaderOpinion.Replace("(领导批示)", "");
                    string sLeaderOpinion = "";
                    sLeaderOpinion = sLeaderOpinion.Replace("\n", "");
                    string[] result = sLeaderOpinion.Split(new char[]{'[', ']'});
                    if (result.Length == 0)
                    {
                        ucPrint.ExportData.Add(sLeaderOpinion); //<col>领导批示:|inner</col>
                    }
                    else
                    {
                        if (result.Length >= 3)
                            ucPrint.ExportData.Add(result[0] + "\n" + result[1] + "\n" + result[2]);
                        else
                            ucPrint.ExportData.Add("");
                    }

                    ucPrint.AttachFileList = cEntity.FileList;
                    //ucPrint.Position = "领导批示:";//(string)ucPrint.ExportData[2];
                    //ucPrint.Mode = WriteMode.Up;
                    break;
                case "请示报告表单":
                    SetBaseExportData(ucPrint, cEntity);
                    //ucPrint.ExportData.Add(cEntity.Message);       //<col>伴随信息:|right</col>
                    //ucPrint.ExportData.Add(cEntity.UndertakeCircs);//<col>批示意见:|right</col>
                    ucPrint.ExportData.Add(cEntity.FenFaFanWei);   //<col>部门:|inner</col>
                    ucPrint.ExportData.Add(cEntity.GongSiLingDao);   //<col>公司领导:|inner</col>
                    //ucPrint.ExportData.Add(cEntity.FenFaFanWei);   //<col>分发范围:|right</col>

                    ucPrint.ExportData.Add(ucPrint.AttachFilesList(cEntity.FileList)); //<col>附件:|down</col>
                    break;
            }
        }
Beispiel #4
0
			public override FileBasedConfig OpenSystemConfig(Config parent, FS fs)
			{
				FilePath prefix = fs.GitPrefix();
				if (prefix == null)
				{
					return new _FileBasedConfig_79(null, fs);
				}
				// empty, do not load
				// regular class would bomb here
				FilePath etc = fs.Resolve(prefix, "etc");
				FilePath config = fs.Resolve(etc, "gitconfig");
				return new FileBasedConfig(parent, config, fs);
			}
Beispiel #5
0
            public FileEntry(FileSystemInfo f)
            {
                _file       = f;
                _fileLength = -1;

                if (_file.IsDirectory())
                {
                    _mode = new DirectoryInfo(_file + "/.git").Exists ? FileMode.GitLink : FileMode.Tree;
                }
                else if (_file.IsFile())
                {
                    _mode = FS.canExecute(_file) ? FileMode.ExecutableFile : FileMode.RegularFile;
                }
            }
Beispiel #6
0
 public SectorStatus GetSectorStatus(ulong sectorNum)
 {
     if (StorageType == StorageType.PhysicalDiskPartition && FS != null)
     {
         return(FS.GetSectorStatus(sectorNum));
     }
     else
     {
         return(SectorStatus.Unknown);
     }
     // TODO: We should probably add a StorageLayer abstraction so that Images
     // can do all the same things as PhysicalDisks/Partitions/Ranges without code duplication.
     // We should probably have a subclass of Image for each of the StorageType values.
 }
		internal static bool CanHandle(URIish uri, FS fs)
		{
			if (uri.GetHost() != null || uri.GetPort() > 0 || uri.GetUser() != null || uri.GetPass
				() != null || uri.GetPath() == null)
			{
				return false;
			}
			if ("file".Equals(uri.GetScheme()) || uri.GetScheme() == null)
			{
				FilePath f = fs.Resolve(new FilePath("."), uri.GetPath());
				return f.IsFile() || f.GetName().EndsWith(".bundle");
			}
			return false;
		}
        public void WorksWhenRenamed()
        {
            var originalExe = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "sce.exe");
            var testDir     = TestUtil.GetTestDir(WorksWhenRenamed);
            var exe         = Path.Combine(testDir, "hello.exe");

            // ensure that source directory is deleted
            FS.EnsureDirectoryIsEmpty(testDir);

            File.Copy(originalExe, exe);

            var sourceDir = exe + ".src";

            // Start first time to create source dir
            var p = Run(exe);

            Assert.AreEqual(0, p.Result.process.ExitCode);

            // modify source
            var programCs = Path.Combine(sourceDir, "Program.cs");

            File.WriteAllText(programCs, @"
using System;

class Program
{
    internal static int Main(string[] args)
    {
        return 123;
    }
}
");


            // Start second time to recompile and return different exit code
            p = Run(exe);
            Assert.AreEqual(123, p.Result.process.ExitCode);

            // Start third time to remove old-sce-hello.exe
            p = Run(exe);
            Assert.AreEqual(123, p.Result.process.ExitCode);

            // delete the source dir
            FS.EnsureDirectoryNotExists(sourceDir);

            // Start to show that without code the default behaviour is restored again
            p = Run(exe);
            Assert.AreEqual(0, p.Result.process.ExitCode);
            Assert.IsTrue(File.Exists(programCs));
        }
Beispiel #9
0
 public Judger()
 {
     sandbox         = new Sandbox();
     problemModel    = new ProblemModel();
     userModel       = new UserModel();
     judgeModel      = new JudgeModel();
     compilerManager = new CompilerManager();
     checker         = new Checker();
     workSpace       = FS.JudgeWorkspace;
     FS.WriteAllBytes(FS.RunEXE, Properties.Resources.run_PCMS2);
     FS.WriteAllBytes(FS.InvokeDLL, Properties.Resources.invoke2_PCMS2);
     FS.WriteAllBytes(FS.CompilerTemplates, Properties.Resources.compilerTemplates);
     FS.CleanAppData();
 }
Beispiel #10
0
        public void GetRelativePathTest3()
        {
            var a1 = @"E:\Documents\vs\Projects\sunamo";
            var a2 = @"E:\Documents\vs\Projects\sunamo\SunamoCef\SunamoCef.csproj";

            var expected = @"SunamoCef\SunamoCef.csproj";

            var result = string.Empty;

            //a1 a2 ..\sunamo\sunamo\sunamo.csproj
            //a2 a1 ..\..\..\EverythingClient\ - working perfectly even if path ending with backslash
            result = FS.GetRelativePath(a1, a2);
            Assert.Equal(expected, result);
        }
        /// <summary>Obtain the user's configuration data.</summary>
        /// <remarks>
        /// Obtain the user's configuration data.
        /// <p>
        /// The configuration file is always returned to the caller, even if no file
        /// exists in the user's home directory at the time the call was made. Lookup
        /// requests are cached and are automatically updated if the user modifies
        /// the configuration file since the last time it was cached.
        /// </remarks>
        /// <param name="fs">
        /// the file system abstraction which will be necessary to
        /// perform certain file system operations.
        /// </param>
        /// <returns>a caching reader of the user's configuration file.</returns>
        public static NGit.Transport.OpenSshConfig Get(FS fs)
        {
            FilePath home = fs.UserHome();

            if (home == null)
            {
                home = new FilePath(".").GetAbsoluteFile();
            }
            FilePath config = new FilePath(new FilePath(home, ".ssh"), Constants.CONFIG);

            NGit.Transport.OpenSshConfig osc = new NGit.Transport.OpenSshConfig(home, config);
            osc.Refresh();
            return(osc);
        }
Beispiel #12
0
        public void Load()
        {
            if (!FS.FileExist(FS.JudgeSettings))
            {
                return;
            }
            string json = File.ReadAllText(FS.JudgeSettings);
            var    tmp  = JsonSerializer.Deserialize <Settings>(json);

            foreach (PropertyInfo property in typeof(Settings).GetProperties().Where(p => p.CanWrite))
            {
                property.SetValue(this, property.GetValue(tmp, null), null);
            }
        }
Beispiel #13
0
        public void GetNameWithoutSeries6()
        {
            bool   hasSerie;
            int    serie;
            string input  = @"D:\a\b\abc_001_01.txt.txt";
            string result = "";
            // just one extension
            string expected = @"abc.txt";

            result = FS.GetNameWithoutSeries(input, false, out hasSerie, Enums.SerieStyle.Underscore, out serie);
            Assert.Equal(expected, result);
            Assert.True(hasSerie);
            Assert.Equal(1, serie);
        }
Beispiel #14
0
        public void ProcessesShowTheirOutput()
        {
            var originalExe = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "sce.exe");
            var testDir     = TestUtil.GetTestDir(ProcessesShowTheirOutput);
            var exe         = Path.Combine(testDir, Path.GetFileName(originalExe));

            // ensure that source directory is deleted
            FS.EnsureDirectoryIsEmpty(testDir);

            File.Copy(originalExe, exe);

            Console.WriteLine("output from Console.WriteLine");
            Run(exe).Wait();
        }
        private async Task <HashSet <string> > GetLatestInclusionStates(string hash, HashSet <string> hashes) // non-public function
        {
            if (hashes.Count == 0)
            {
                return(null);
            }

            // get a list of confirmed TXs to the given address
            var callerID = $"{nameof(GetLatestInclusionStates)}::{hash}";

            // Get from a partial cache - list of confirmed TX hashes
            var cached = await FS.GetFSPartialCacheEntryAsync(call : callerID);

            var CachedOutput    = cached == null ? new HashSet <string>() : (HashSet <string>)cached;
            var loadedfromcache = CachedOutput.Count();

            hashes.ExceptWith(CachedOutput); // removing all hashes that were already confirmed

            InclusionStates  res;
            HashSet <string> OnlyNewlyConfirmedHashes = null;

            if (hashes.Count > 0) // are there any non-confirmed left?
            {
                try
                {
                    res = await Repo.GetLatestInclusionAsync((from h in hashes select new Hash(h)).ToList());
                }
                catch (Exception)
                {
                    throw;
                }

                OnlyNewlyConfirmedHashes = (from v in res.States where v.Value == true select v.Key.Value).ToHashSet();

                if (OnlyNewlyConfirmedHashes.Count > 0)
                {
                    CachedOutput.UnionWith(OnlyNewlyConfirmedHashes); // saving all back to the cache
                                                                      //Write to partial cache
                    await FS.AddFSPartialCacheEntryAsync(
                        call : callerID,
                        result : CachedOutput);
                }
            }

            Logger.LogInformation("{callerID} in action. {loadedfromcache} confirmed hashes loaded from cache. {OnlyNewlyConfirmedHashes.Count} hashes were new ones.", callerID.Substring(0, 25), loadedfromcache, OnlyNewlyConfirmedHashes?.Count);

            //returning all from cache + new one from API call
            return(CachedOutput);
        }
        public static BlastLayer CloudLoad(string CorruptCloudCode)
        {
            GlobalWin.Sound.StopSound();
            //string obj = SerializeObject(bl);
            //string Code = "";


            string remoteUri = CorruptCloudServer + "/FILES/";
            string ccc       = CorruptCloudCode;

            WebClient myWebClient = new WebClient();

            try
            {
                GlobalWin.Sound.StopSound();
                myWebClient.DownloadFile(remoteUri + ccc, RTC_Core.rtcDir + "\\CORRUPTCLOUD\\" + ccc);
            }
            catch (Exception ex)
            {
                GlobalWin.Sound.StopSound();
                MessageBox.Show("Error: Couldn't get requested BlastLayer\n\n\n" + ex.ToString());
                GlobalWin.Sound.StartSound();
                return(null);
            }

            BlastLayer bl;

            FileStream      FS;
            BinaryFormatter bformatter = new BinaryFormatter();

            try
            {
                GlobalWin.Sound.StopSound();
                FS = File.Open(RTC_Core.rtcDir + "\\CORRUPTCLOUD\\" + ccc, FileMode.OpenOrCreate);
                bl = (BlastLayer)bformatter.Deserialize(FS);
                FS.Close();
            }
            catch (Exception ex)
            {
                GlobalWin.Sound.StopSound();
                MessageBox.Show("The BlastLayer file could not be loaded\n\n\n" + ex.ToString());
                GlobalWin.Sound.StartSound();
                return(null);
            }

            GlobalWin.Sound.StartSound();

            return(bl);
        }
Beispiel #17
0
        /**
         * SV_CheckForSavegame.
         */
        public static void SV_CheckForSavegame()
        {
            string name;

            int i;

            if (SV_MAIN.sv_noreload.value != 0)
            {
                return;
            }

            if (Cvar.VariableValue("deathmatch") != 0)
            {
                return;
            }

            name = FS.Gamedir() + "/save/current/" + SV_INIT.sv.name + ".sav";

            if (!File.Exists(name))
            {
                return;
            }

            SV_WORLD.SV_ClearWorld();

            // get configstrings and areaportals
            SV_CCMDS.SV_ReadLevelFile();

            if (!SV_INIT.sv.loadgame)
            {
                // coming back to a level after being in a different
                // level, so run it for ten seconds

                // rlava2 was sending too many lightstyles, and overflowing the
                // reliable data. temporarily changing the server state to loading
                // prevents these from being passed down.
                int previousState;                     // PGM

                previousState    = SV_INIT.sv.state;   // PGM
                SV_INIT.sv.state = Defines.ss_loading; // PGM

                for (i = 0; i < 100; i++)
                {
                    GameBase.G_RunFrame();
                }

                SV_INIT.sv.state = previousState;                 // PGM
            }
        }
 public void SetPrintAttachExport(UC_Print ucPrint, FS.ADIM.OA.BLL.Busi.Process.B_Finance cEntity)
 {
     switch (ucPrint.FileName)
     {
         case "公司报告":
         case "公司请示":
             ucPrint.WriteContent("领导批示:", WriteMode.Up, 1);
             ucPrint.WriteAttach();
             break;
         case "请示报告表单":
             //ucPrint.WriteContent("内容:", WriteMode.Down, 1);
             //ucPrint.WriteAttach();
             break;
     }
 }
Beispiel #19
0
        public void Should_match_paths_at_a_lower_level_than_suggested_path()
        {
            _fs.Stub(x => x.DirectoryExists(Path.Combine(FS.GetTempPath(), "EditorEngine"))).Return(true);
            _client.Stub(x => x.IsConnected).Return(true);
            _fs.Stub(x => x.GetFiles(Path.Combine(FS.GetTempPath(), "EditorEngine"), "*.pid")).Return(new string[] { "123.pid", "2345.pid", "8754.pid" });
            _fs.Stub(x => x.ReadLines("123.pid")).Return(new string[] { "/some/path/here/too", "234" });
            _fs.Stub(x => x.ReadLines("2345.pid")).Return(new string[] { "/some/path", "876" });
            _fs.Stub(x => x.ReadLines("8754.pid")).Return(new string[] { "Other stuff", "1" });
            var instance = _locator.GetInstance("/some/path/here");

            Assert.That(instance.File, Is.EqualTo("2345.pid"));
            Assert.That(instance.ProcessID, Is.EqualTo(2345));
            Assert.That(instance.Key, Is.EqualTo("/some/path"));
            Assert.That(instance.Port, Is.EqualTo(876));
        }
        internal RefDirectory(FileRepository db)
        {
            //$NON-NLS-1$
            //$NON-NLS-1$
            //$NON-NLS-1$
            FS fs = db.FileSystem;

            parent         = db;
            gitDir         = db.Directory;
            logWriter      = new ReflogWriter(db);
            refsDir        = fs.Resolve(gitDir, Constants.R_REFS);
            packedRefsFile = fs.Resolve(gitDir, Constants.PACKED_REFS);
            looseRefs.Set(RefList.EmptyList <RefDirectory.LooseRef>());
            packedRefs.Set(RefDirectory.PackedRefList.NO_PACKED_REFS);
        }
Beispiel #21
0
        public void Should_matching_on_two_paths_choose_closest_path()
        {
            _fs.Stub(x => x.DirectoryExists(FS.GetTempPath())).Return(true);
            _client.Stub(x => x.IsConnected).Return(true);
            _fs.Stub(x => x.GetFiles(FS.GetTempPath(), _filepattern)).Return(toFiles(new string[] { "123.EditorEngine.user.pid", "2345.EditorEngine.user.pid", "8754.EditorEngine.user.pid" }));
            _fs.Stub(x => x.ReadLines(toFile("123.EditorEngine.user.pid"))).Return(new string[] { "/some/path", "234" });
            _fs.Stub(x => x.ReadLines(toFile("2345.EditorEngine.user.pid"))).Return(new string[] { "/some/path/here", "876" });
            _fs.Stub(x => x.ReadLines(toFile("8754.EditorEngine.user.pid"))).Return(new string[] { "Other stuff", "1" });
            var instance = _locator.GetInstance("/some/path/here");

            Assert.That(instance.File, Is.EqualTo(toFile("2345.EditorEngine.user.pid")));
            Assert.That(instance.ProcessID, Is.EqualTo(2345));
            Assert.That(instance.Key, Is.EqualTo("/some/path/here"));
            Assert.That(instance.Port, Is.EqualTo(876));
        }
Beispiel #22
0
        private void writeInstanceInfo(string key)
        {
            var path = Path.Combine(FS.GetTempPath(), "OpenIDE.Events");

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            _instanceFile = Path.Combine(path, string.Format("{0}.pid", Process.GetCurrentProcess().Id));
            var sb = new StringBuilder();

            sb.AppendLine(key);
            sb.AppendLine(_server.Port.ToString());
            File.WriteAllText(_instanceFile, sb.ToString());
        }
Beispiel #23
0
        public static void SV_GameMap_f( )
        {
            if (Cmd.Argc() != 2)
            {
                Com.Printf("USAGE: gamemap <map>\\n");
                return;
            }

            Com.DPrintf("SV_GameMap(" + Cmd.Argv(1) + ")\\n");
            FS.CreatePath(FS.Gamedir() + "/save/current/");
            var map = Cmd.Argv(1);

            if (map[0] == '*')
            {
                SV_WipeSavegame("current");
            }
            else
            {
                if (SV_INIT.sv.state == Defines.ss_game)
                {
                    client_t  cl;
                    Boolean[] savedInuse = new Boolean[( Int32 )SV_MAIN.maxclients.value];
                    for (var i = 0; i < SV_MAIN.maxclients.value; i++)
                    {
                        cl             = SV_INIT.svs.clients[i];
                        savedInuse[i]  = cl.edict.inuse;
                        cl.edict.inuse = false;
                    }

                    SV_WriteLevelFile();
                    for (var i = 0; i < SV_MAIN.maxclients.value; i++)
                    {
                        cl             = SV_INIT.svs.clients[i];
                        cl.edict.inuse = savedInuse[i];
                    }

                    savedInuse = null;
                }
            }

            SV_INIT.SV_Map(false, Cmd.Argv(1), false);
            SV_INIT.svs.mapcmd = Cmd.Argv(1);
            if (0 == Globals.dedicated.value)
            {
                SV_WriteServerFile(true);
                SV_CopySaveGame("current", "save0");
            }
        }
Beispiel #24
0
        /// <summary>
        /// Executes the specified parameter.
        /// </summary>
        /// <param name="param">The parameter.</param>
        public override void Execute(string param)
		{
			if (param == "sysinfo")
			{
				SystemFunctions.PrintInfo();
			}
            else if (param == "ram_info")
            {
                SystemFunctions.PrintRAMInfo();
            }
			else if (param == "ram_used")
			{
				SystemFunctions.PrintUsedRAM();
			}
			else if (param == "ram_free")
			{
				SystemFunctions.PrintFreeRAM();
			}
			else if (param == "ram_total")
			{
				SystemFunctions.PrintTotalRAM();
			}
			else if (param == "host")
			{
				Console.WriteLine(Kernel.Host);
			}
			else if (param == "lspci")
			{
				SystemFunctions.lspci();
			}
            else if (param == "lscpu")
            {
                SystemFunctions.lscpu();
            }
            else if (param == "list_vols")
			{
				FS.ListVols();
			}
			else if (param == "list_vol")
			{
				FS.ListVol();
			}
            else if (param == "fs_log")
            {
                Console.WriteLine("FS Log:");
                Console.WriteLine(ServiceLogging.PrintLog(MCS.FSService.ServiceLogger));
            }
		}
Beispiel #25
0
        private IEnumerable <Instance> getInstances()
        {
            var dir = Path.Combine(FS.GetTempPath(), "OpenIDE.CodeEngine");

            if (_fs.DirectoryExists(dir))
            {
                foreach (var file in _fs.GetFiles(dir, "*.pid"))
                {
                    var instance = Instance.Get(ClientFactory, file, _fs.ReadLines(file));
                    if (instance != null)
                    {
                        yield return(instance);
                    }
                }
            }
        }
Beispiel #26
0
        private void CreateDummyFile(DotNetCli dotnet, string intermediateDirectory)
        {
            var dummyTxt = "dummy text";

            var tempPjDirectory = Path.Combine(intermediateDirectory, "dummyNuGetPackageIntermediate");

            FS.Rmdir(tempPjDirectory);

            Directory.CreateDirectory(tempPjDirectory);

            var dummyTextFile = Path.Combine(tempPjDirectory, "dummy.txt");

            File.WriteAllText(dummyTextFile, dummyTxt);

            _dummyFileCreated = true;
        }
Beispiel #27
0
        public Index <ApiCodeBlock> Read(ApiHostUri host)
        {
            var file = FS.file(host.Part, host.HostName, Ext);
            var path = Paths().Where(f => f.FileName.Name == file.Name).FirstOrDefault(FS.FilePath.Empty);

            if (path.IsEmpty)
            {
                Wf.Warn(Msg.HostFileMissing.Format(host, path));
                return(sys.empty <ApiCodeBlock>());
            }
            var flow = Wf.Running(path);
            var data = Read(path);

            Wf.Ran(flow, data.Length);
            return(data);
        }
Beispiel #28
0
    public void GenerateFilesCsFileFilterTests()
    {
        var fi = GetConsts();

        foreach (var item in fi)
        {
            if (item.Name.EndsWith("Pp"))
            {
                var path = FS.Combine(p, "auto", "+" + item.GetValue(null));
                if (!FS.ExistsFile(path, false))
                {
                    TF.WriteAllText(path, "a");
                }
            }
        }
    }
Beispiel #29
0
    public void XmlAgilityDocumentTest()
    {
        var c = @"D:\_Test\sunamo\sunamo\Xml\XmlAgilityDocumentTests\input.csproj";
        XmlAgilityDocument x = new XmlAgilityDocument();

        x.Load(c);
        var nodes = HtmlAgilityHelper.NodesWithAttrWildCard(x.hd.DocumentNode, true, "Compile", Consts.Include, "*.cs", true);

        foreach (var item in nodes)
        {
            item.Remove();
        }

        x.path = FS.ChangeFilename(x.path, "output.csproj", false);
        x.Save();
    }
Beispiel #30
0
        private IEnumerable <Instance> getInstances(string path)
        {
            var dir = Path.Combine(FS.GetTempPath(), "OpenIDE.Events");

            if (Directory.Exists(dir))
            {
                foreach (var file in Directory.GetFiles(dir, "*.pid"))
                {
                    var instance = Instance.Get(file, File.ReadAllLines(file));
                    if (instance != null)
                    {
                        yield return(instance);
                    }
                }
            }
        }
Beispiel #31
0
        public List <string> GetSubmissionPath(string problemName, string userName)
        {
            User user = userModel[userName];

            problemName = problemName.ToLower();
            List <string> result = new List <string>();

            foreach (UserSubmission sub in user.UserSubmissions)
            {
                if (sub.Name.ToLower() == problemName)
                {
                    result.Add(FS.Combine(userModel.UserDirectory, userName, sub.ToString()));
                }
            }
            return(result);
        }
        public void data()
        {
            my_list = new ArrayList();
            RestClient restClient = new RestClient("http://baraadervis.pythonanywhere.com/FS/fs-results-api/", RestClient.httpVerb.GET);
            string     resp       = restClient.makeRequestWithToken();

            var o = JObject.Parse(resp);


            JArray a = JArray.Parse(o["results"].ToString());

            FS myObj = new FS();

            foreach (JObject obj in a.Children <JObject>())
            {
                myObj = new FS();
                foreach (JProperty objprop in obj.Properties())
                {
                    if (objprop.Name == "old_accuracy")
                    {
                        myObj.old_accuracy = Math.Round(Double.Parse(objprop.Value.ToString()), 3, MidpointRounding.ToEven);
                    }

                    else if (objprop.Name == "new_accurcay")
                    {
                        myObj.new_accuracy = Math.Round(Double.Parse(objprop.Value.ToString()), 2, MidpointRounding.ToEven);
                    }
                    else if (objprop.Name == "name")
                    {
                        myObj.name = objprop.Value.ToString();
                    }
                    else if (objprop.Name == "old_features")
                    {
                        myObj.old_features = int.Parse(objprop.Value.ToString());
                    }
                    else if (objprop.Name == "new_features")
                    {
                        myObj.new_features = int.Parse(objprop.Value.ToString());
                    }
                }
                my_list.Add(myObj);
            }
            foreach (FS f in my_list)
            {
                fs_datagrid.Items.Add(f);
            }
        }
Beispiel #33
0
        static private List <RepositoryListener> allListeners = new List <RepositoryListener>(); //TODO: make thread safe

        /**
         * Construct a representation of a Git repository.
         *
         * @param d
         *            GIT_DIR (the location of the repository metadata).
         * @throws IOException
         *             the repository appears to already exist but cannot be
         *             accessed.
         */
        public Repository(DirectoryInfo gitDirectory)
        {
            Directory       = gitDirectory;
            _refDb          = new RefDatabase(this);
            _objectDatabase = new ObjectDirectory(new DirectoryInfo(FS.resolve(gitDirectory, "objects").FullName));

            var userConfig = SystemReader.getInstance().openUserConfig();

            try
            {
                userConfig.load();
            }
            catch (ConfigInvalidException e1)
            {
                Dispose();

                throw new IOException("User config file "
                                      + userConfig.getFile().FullName + " invalid: "
                                      + e1, e1);
            }

            Config = new RepositoryConfig(userConfig, (FileInfo)FS.resolve(gitDirectory, "config"));

            WorkingDirectory = gitDirectory.Parent;

            if (_objectDatabase.exists())
            {
                try
                {
                    Config.load();
                }
                catch (ConfigInvalidException e1)
                {
                    Dispose();
                    throw new IOException("Unknown repository format", e1);
                }

                string repositoryFormatVersion = Config.getString("core", null, "repositoryFormatVersion");

                if (!"0".Equals(repositoryFormatVersion))
                {
                    Dispose();
                    throw new IOException("Unknown repository format \""
                                          + repositoryFormatVersion + "\"; expected \"0\".");
                }
            }
        }
Beispiel #34
0
        public static void SV_CheckForSavegame( )
        {
            String     name;
            FileStream f;
            Int32      i;

            if (SV_MAIN.sv_noreload.value != 0)
            {
                return;
            }
            if (Cvar.VariableValue("deathmatch") != 0)
            {
                return;
            }
            name = FS.Gamedir() + "/save/current/" + sv.name + ".sav";
            try
            {
                f = File.OpenRead(name);
            }
            catch (Exception e)
            {
                return;
            }

            try
            {
                f.Close();
            }
            catch (Exception e1)
            {
                e1.PrintStackTrace();
            }

            SV_WORLD.SV_ClearWorld();
            SV_CCMDS.SV_ReadLevelFile();
            if (!sv.loadgame)
            {
                Int32 previousState;
                previousState = sv.state;
                sv.state      = Defines.ss_loading;
                for (i = 0; i < 100; i++)
                {
                    GameBase.G_RunFrame();
                }
                sv.state = previousState;
            }
        }
        public static string CloudSave(BlastLayer bl)
        {
            FileStream      FS;
            BinaryFormatter bformatter = new BinaryFormatter();

            string tempfile = RTC_Core.rtcDir + "\\CORRUPTCLOUD\\temp.bl";

            GlobalWin.Sound.StopSound();

            if (File.Exists(tempfile))
            {
                File.Delete(tempfile);
            }

            FS = File.Open(tempfile, FileMode.OpenOrCreate);
            bformatter.Serialize(FS, bl);
            FS.Close();


            string remoteUri = CorruptCloudServer + "/post.php?submit=true&action=upload";

            byte[] responseBinary;
            try{
                WebClient client = new WebClient();
                responseBinary = client.UploadFile(remoteUri, "POST", tempfile);
            }
            catch (Exception ex)
            {
                GlobalWin.Sound.StopSound();
                MessageBox.Show("Something went wrong with the upload. Try again. \n\n\n" + ex.ToString());
                GlobalWin.Sound.StartSound();
                return("");
            }

            string response = Encoding.UTF8.GetString(responseBinary);

            GlobalWin.Sound.StartSound();

            if (response == "ERROR")
            {
                return("");
            }
            else
            {
                return(response);
            }
        }
Beispiel #36
0
        private Control CreateReport()
        {
            var result     = new TemplateBillReport();
            var parameters = new Dictionary <string, object>();



            parameters.Add("$CurrentUserName", BLContext.User.Name);


            AddParameters(parameters);

            var autoAdd = new Dictionary <string, object>();

            foreach (KeyValuePair <string, object> pair in parameters)
            {
                if (pair.Value != null && pair.Value is ICollection)
                {
                    string newKey = pair.Key + "_RecordCount";
                    if (!parameters.ContainsKey(newKey))
                    {
                        autoAdd.Add(newKey, ((ICollection)pair.Value).Count);
                    }
                }
                else if (pair.Value != null && pair.Value is LoadArguments)
                {
                    string newKey = pair.Key + "_RecordCount";
                    if (!parameters.ContainsKey(newKey))
                    {
                        var loadArguments = new LoadArguments(((LoadArguments)pair.Value).DQuery.Clone() as DQueryDom);
                        loadArguments.DQuery.Range = SelectRange.Top(0);
                        var adapater = new DFDataAdapter(loadArguments);
                        var table    = adapater.PagedFill();
                        autoAdd.Add(newKey, table.TotalCount);
                    }
                }
            }
            foreach (KeyValuePair <string, object> pair in autoAdd)
            {
                parameters.Add(pair.Key, pair.Value);
            }

            var printTemplateFile = Path.Combine(Wpf.Settings.ConfigFolder, GetTemplateFile());

            result.ParseTemplate(FS.OpenRead(printTemplateFile), parameters);
            return(result);
        }
		/// <exception cref="NSch.JSchException"></exception>
		public override Session GetSession(string user, string pass, string host, int port
			, CredentialsProvider credentialsProvider, FS fs)
		{
			lock (this)
			{
				if (config == null)
				{
					config = OpenSshConfig.Get(fs);
				}
				OpenSshConfig.Host hc = config.Lookup(host);
				host = hc.GetHostName();
				if (port <= 0)
				{
					port = hc.GetPort();
				}
				if (user == null)
				{
					user = hc.GetUser();
				}
				Session session = CreateSession(hc, user, host, port, fs);
				if (pass != null)
				{
					session.SetPassword(pass);
				}
				string strictHostKeyCheckingPolicy = hc.GetStrictHostKeyChecking();
				if (strictHostKeyCheckingPolicy != null)
				{
					session.SetConfig("StrictHostKeyChecking", strictHostKeyCheckingPolicy);
				}
				string pauth = hc.GetPreferredAuthentications();
				if (pauth != null)
				{
					session.SetConfig("PreferredAuthentications", pauth);
				}
				if (credentialsProvider != null && (!hc.IsBatchMode() || !credentialsProvider.IsInteractive
					()))
				{
					session.SetUserInfo(new CredentialsProviderUserInfo(session, credentialsProvider)
						);
				}
				Configure(hc, session);
				return session;
			}
		}
Beispiel #38
0
			/// <summary>Guess if a directory contains a Git repository.</summary>
			/// <remarks>
			/// Guess if a directory contains a Git repository.
			/// <p>
			/// This method guesses by looking for the existence of some key files
			/// and directories.
			/// </remarks>
			/// <param name="dir">the location of the directory to examine.</param>
			/// <param name="fs">
			/// the file system abstraction which will be necessary to
			/// perform certain file system operations.
			/// </param>
			/// <returns>
			/// true if the directory "looks like" a Git repository; false if
			/// it doesn't look enough like a Git directory to really be a
			/// Git directory.
			/// </returns>
			public static bool IsGitRepository(FilePath dir, FS fs)
			{
				return fs.Resolve(dir, "objects").Exists() && fs.Resolve(dir, "refs").Exists() &&
					 IsValidHead(new FilePath(dir, Constants.HEAD));
			}
Beispiel #39
0
			/// <param name="directory">exact location of the repository.</param>
			/// <param name="fs">
			/// the file system abstraction which will be necessary to
			/// perform certain file system operations.
			/// </param>
			protected internal FileKey(FilePath directory, FS fs)
			{
				path = Canonical(directory);
				this.fs = fs;
			}
Beispiel #40
0
			/// <summary>Obtain a pointer to a location on disk.</summary>
			/// <remarks>
			/// Obtain a pointer to a location on disk.
			/// <p>
			/// The method performs some basic guessing to locate the repository.
			/// Searched paths are:
			/// <ol>
			/// <li>
			/// <code>directory</code>
			/// // assume exact match</li>
			/// <li>
			/// <code>directory</code>
			/// + "/.git" // assume working directory</li>
			/// <li>
			/// <code>directory</code>
			/// + ".git" // assume bare</li>
			/// </ol>
			/// </remarks>
			/// <param name="directory">location where the repository database might be.</param>
			/// <param name="fs">
			/// the file system abstraction which will be necessary to
			/// perform certain file system operations.
			/// </param>
			/// <returns>a key for the given directory.</returns>
			/// <seealso cref="Exact(Sharpen.FilePath, NGit.Util.FS)">Exact(Sharpen.FilePath, NGit.Util.FS)
			/// 	</seealso>
			public static RepositoryCache.FileKey Lenient(FilePath directory, FS fs)
			{
				FilePath gitdir = Resolve(directory, fs);
				return new RepositoryCache.FileKey(gitdir != null ? gitdir : directory, fs);
			}
        /// <exception cref="NGit.Errors.TransportException"></exception>
        public override RemoteSession GetSession(URIish uri, CredentialsProvider credentialsProvider
			, FS fs, int tms)
        {
            lock (this)
            {
                string user = uri.GetUser();
                string pass = uri.GetPass();
                string host = uri.GetHost();
                int port = uri.GetPort();
                try
                {
                    if (config == null)
                    {
                        config = OpenSshConfig.Get(fs);
                    }
                    OpenSshConfig.Host hc = config.Lookup(host);
                    host = hc.GetHostName();
                    if (port <= 0)
                    {
                        port = hc.GetPort();
                    }
                    if (user == null)
                    {
                        user = hc.GetUser();
                    }
                    Session session = CreateSession(credentialsProvider, fs, user, pass, host, port,
                        hc);
                    int retries = 0;
                    while (!session.IsConnected() && retries < 3)
                    {
                        try
                        {
                            retries++;
                            session.Connect(tms);
                        }
                        catch (JSchException e)
                        {
                            session.Disconnect();
                            session = null;
                            // if authentication failed maybe credentials changed at the
                            // remote end therefore reset credentials and retry
                            if (credentialsProvider != null && e.InnerException == null && e.Message.Equals("Auth fail"
                                ))
                            {
                                credentialsProvider.Reset(uri);
                                session = CreateSession(credentialsProvider, fs, user, pass, host, port, hc);
                            }
                            else
                            {
                                throw;
                            }
                        }
                    }
                    return new JschSession(session, uri);
                }
                catch (JSchException je)
                {
                    Exception c = je.InnerException;
                    if (c is UnknownHostException)
                    {
                        throw new TransportException(uri, JGitText.Get().unknownHost);
                    }
                    if (c is ConnectException)
                    {
                        throw new TransportException(uri, c.Message);
                    }
                    throw new TransportException(uri, je.Message, je);
                }
            }
        }
Beispiel #42
0
 /// <summary>Create a new lock for any file.</summary>
 /// <remarks>Create a new lock for any file.</remarks>
 /// <param name="f">the file that will be locked.</param>
 /// <param name="fs">
 /// the file system abstraction which will be necessary to perform
 /// certain file system operations.
 /// </param>
 public LockFile(FilePath f, FS fs)
 {
     @ref = f;
     lck = GetLockFile(@ref);
     this.fs = fs;
 }
Beispiel #43
0
		/// <param name="fs">
		/// the file system abstraction which will be necessary to
		/// perform certain file system operations.
		/// </param>
		/// <returns>the git configuration found in the user home</returns>
		public abstract FileBasedConfig OpenUserConfig(FS fs);
Beispiel #44
0
			internal FileEntry(FilePath f, FS fs)
			{
				file = f;
				if (f.IsDirectory())
				{
					if (new FilePath(f, Constants.DOT_GIT).Exists())
					{
						mode = FileMode.GITLINK;
					}
					else
					{
						mode = FileMode.TREE;
					}
				}
				else
				{
					if (fs.CanExecute(file))
					{
						mode = FileMode.EXECUTABLE_FILE;
					}
					else
					{
						mode = FileMode.REGULAR_FILE;
					}
				}
			}
Beispiel #45
0
 public EFS()
 {
     ED = new ED();
     FS = new FS();
     IFG = new IFG();
 }
Beispiel #46
0
		protected internal FS_POSIX_Java6(FS src) : base(src)
		{
		}
Beispiel #47
0
		/// <summary>Create a new lock for any file.</summary>
		/// <remarks>Create a new lock for any file.</remarks>
		/// <param name="f">the file that will be locked.</param>
		/// <param name="fs">
		/// the file system abstraction which will be necessary to perform
		/// certain file system operations.
		/// </param>
		public LockFile(FilePath f, FS fs)
		{
			@ref = f;
			lck = new FilePath(@ref.GetParentFile(), @ref.GetName() + SUFFIX);
			this.fs = fs;
		}
Beispiel #48
0
			/// <summary>Guess the proper path for a Git repository.</summary>
			/// <remarks>
			/// Guess the proper path for a Git repository.
			/// <p>
			/// The method performs some basic guessing to locate the repository.
			/// Searched paths are:
			/// <ol>
			/// <li>
			/// <code>directory</code>
			/// // assume exact match</li>
			/// <li>
			/// <code>directory</code>
			/// + "/.git" // assume working directory</li>
			/// <li>
			/// <code>directory</code>
			/// + ".git" // assume bare</li>
			/// </ol>
			/// </remarks>
			/// <param name="directory">location to guess from. Several permutations are tried.</param>
			/// <param name="fs">
			/// the file system abstraction which will be necessary to
			/// perform certain file system operations.
			/// </param>
			/// <returns>
			/// the actual directory location if a better match is found;
			/// null if there is no suitable match.
			/// </returns>
			public static FilePath Resolve(FilePath directory, FS fs)
			{
				if (IsGitRepository(directory, fs))
				{
					return directory;
				}
				if (IsGitRepository(new FilePath(directory, Constants.DOT_GIT), fs))
				{
					return new FilePath(directory, Constants.DOT_GIT);
				}
				string name = directory.GetName();
				FilePath parent = directory.GetParentFile();
				if (IsGitRepository(new FilePath(parent, name + Constants.DOT_GIT_EXT), fs))
				{
					return new FilePath(parent, name + Constants.DOT_GIT_EXT);
				}
				return null;
			}
Beispiel #49
0
		/// <summary>Create a new iterator to traverse a subdirectory.</summary>
		/// <remarks>Create a new iterator to traverse a subdirectory.</remarks>
		/// <param name="p">the parent iterator we were created from.</param>
		/// <param name="fs">
		/// the file system abstraction which will be necessary to perform
		/// certain file system operations.
		/// </param>
		/// <param name="root">
		/// the subdirectory. This should be a directory contained within
		/// the parent directory.
		/// </param>
		protected internal FileTreeIterator(NGit.Treewalk.FileTreeIterator p, FilePath root
			, FS fs) : base(p)
		{
			directory = root;
			this.fs = fs;
			Init(Entries());
		}
		public FileTreeIteratorWithTimeControl(FileTreeIterator p, FilePath f, FS fs, TreeSet
			<long> modTimes) : base(p, f, fs)
		{
			this.modTimes = modTimes;
		}
Beispiel #51
0
		/// <summary>Create a new iterator to traverse the given directory and its children.</summary>
		/// <remarks>Create a new iterator to traverse the given directory and its children.</remarks>
		/// <param name="root">
		/// the starting directory. This directory should correspond to
		/// the root of the repository.
		/// </param>
		/// <param name="fs">
		/// the file system abstraction which will be necessary to perform
		/// certain file system operations.
		/// </param>
		/// <param name="options">working tree options to be used</param>
		public FileTreeIterator(FilePath root, FS fs, WorkingTreeOptions options) : base(
			options)
		{
			directory = root;
			this.fs = fs;
			Init(Entries());
		}
		public FileTreeIteratorWithTimeControl(FilePath f, FS fs, TreeSet<long> modTimes)
			 : base(f, fs, new Config().Get(WorkingTreeOptions.KEY))
		{
			this.modTimes = modTimes;
		}
Beispiel #53
0
			public override FileBasedConfig OpenUserConfig(FS fs)
			{
				FilePath home = fs.UserHome();
				return new FileBasedConfig(new FilePath(home, ".gitconfig"), fs);
			}
Beispiel #54
0
			/// <summary>Obtain a pointer to an exact location on disk.</summary>
			/// <remarks>
			/// Obtain a pointer to an exact location on disk.
			/// <p>
			/// No guessing is performed, the given location is exactly the GIT_DIR
			/// directory of the repository.
			/// </remarks>
			/// <param name="directory">location where the repository database is.</param>
			/// <param name="fs">
			/// the file system abstraction which will be necessary to
			/// perform certain file system operations.
			/// </param>
			/// <returns>a key for the given directory.</returns>
			/// <seealso cref="Lenient(Sharpen.FilePath, NGit.Util.FS)">Lenient(Sharpen.FilePath, NGit.Util.FS)
			/// 	</seealso>
			public static RepositoryCache.FileKey Exact(FilePath directory, FS fs)
			{
				return new RepositoryCache.FileKey(directory, fs);
			}
Beispiel #55
0
 public ScanFSEventSink(FS.ScanFS scanner, int delay)
 {
     m_scanFS = scanner;
     m_delay = delay;
     m_scanFS.FileFound += new EventHandler<FSScanEventArgs>(m_scanFS_FileFound);
 }
        /// <exception cref="NSch.JSchException"></exception>
        private Session CreateSession(CredentialsProvider credentialsProvider, FS fs, string
			 user, string pass, string host, int port, OpenSshConfig.Host hc)
        {
            Session session = CreateSession(hc, user, host, port, fs);
            if (pass != null)
            {
                session.SetPassword(pass);
            }
            string strictHostKeyCheckingPolicy = hc.GetStrictHostKeyChecking();
            if (strictHostKeyCheckingPolicy != null)
            {
                session.SetConfig("StrictHostKeyChecking", strictHostKeyCheckingPolicy);
            }
            string pauth = hc.GetPreferredAuthentications();
            if (pauth != null)
            {
                session.SetConfig("PreferredAuthentications", pauth);
            }
            if (credentialsProvider != null && (!hc.IsBatchMode() || !credentialsProvider.IsInteractive
                ()))
            {
                session.SetUserInfo(new CredentialsProviderUserInfo(session, credentialsProvider)
                    );
            }
            Configure(hc, session);
            return session;
        }
			/// <exception cref="NGit.Errors.TransportException"></exception>
			public override RemoteSession GetSession(URIish uri2, CredentialsProvider credentialsProvider
				, FS fs, int tms)
			{
				return new TransportGitSsh.ExtSession(_enclosing);
			}
		/// <summary>Initialize a reference to an on-disk object directory.</summary>
		/// <remarks>Initialize a reference to an on-disk object directory.</remarks>
		/// <param name="cfg">configuration this directory consults for write settings.</param>
		/// <param name="dir">the location of the <code>objects</code> directory.</param>
		/// <param name="alternatePaths">a list of alternate object directories</param>
		/// <param name="fs">
		/// the file system abstraction which will be necessary to perform
		/// certain file system operations.
		/// </param>
		/// <exception cref="System.IO.IOException">an alternate object cannot be opened.</exception>
		public ObjectDirectory(Config cfg, FilePath dir, FilePath[] alternatePaths, FS fs
			)
		{
			config = cfg;
			objects = dir;
			infoDirectory = new FilePath(objects, "info");
			packDirectory = new FilePath(objects, "pack");
			alternatesFile = new FilePath(infoDirectory, "alternates");
			cachedPacksFile = new FilePath(infoDirectory, "cached-packs");
			packList = new AtomicReference<ObjectDirectory.PackList>(NO_PACKS);
			cachedPacks = new AtomicReference<ObjectDirectory.CachedPackList>();
			unpackedObjectCache = new UnpackedObjectCache();
			this.fs = fs;
			alternates = new AtomicReference<FileObjectDatabase.AlternateHandle[]>();
			if (alternatePaths != null)
			{
				FileObjectDatabase.AlternateHandle[] alt;
				alt = new FileObjectDatabase.AlternateHandle[alternatePaths.Length];
				for (int i = 0; i < alternatePaths.Length; i++)
				{
					alt[i] = OpenAlternate(alternatePaths[i]);
				}
				alternates.Set(alt);
			}
		}
Beispiel #59
0
		/// <param name="dir">
		/// the repository to open. May be either the GIT_DIR, or the
		/// working tree directory that contains
		/// <code>.git</code>
		/// .
		/// </param>
		/// <param name="fs">filesystem abstraction to use when accessing the repository.</param>
		/// <returns>
		/// a
		/// <see cref="Git">Git</see>
		/// object for the existing git repository
		/// </returns>
		/// <exception cref="System.IO.IOException">System.IO.IOException</exception>
		public static NGit.Api.Git Open(FilePath dir, FS fs)
		{
			RepositoryCache.FileKey key;
			key = RepositoryCache.FileKey.Lenient(dir, fs);
			return Wrap(new RepositoryBuilder().SetFS(fs).SetGitDir(key.GetFile()).SetMustExist
				(true).Build());
		}
Beispiel #60
0
		/// <summary>Create a configuration with no default fallback.</summary>
		/// <remarks>Create a configuration with no default fallback.</remarks>
		/// <param name="cfgLocation">the location of the configuration file on the file system
		/// 	</param>
		/// <param name="fs">
		/// the file system abstraction which will be necessary to perform
		/// certain file system operations.
		/// </param>
		public FileBasedConfig(FilePath cfgLocation, FS fs) : this(null, cfgLocation, fs)
		{
		}