public SshGateSession(SshUserData user1, SshUserData user2, ISftpAccount account) : base(account, user2.Prompt) { this.gwchain = new Gen::List <SshUserData>(); this.gwchain.Add(user1); this.gwchain.Add(user2); }
private int c_lines; // 行の数 /// <summary> /// MultilineString の新しいインスタンスを生成します。 /// </summary> /// <param name="text">何行何列目と何文字目の対応を付ける文字列を指定します。</param> public MultilineString(string text) { Gen::List <int> lines = new Gen::List <int>(); lines.Add(0); bool lineend = false, cr = false; for (int i = 0, iM = text.Length; i < iM; i++) { if (text[i] == '\n') { if (lineend && !cr) { lines.Add(i); // 前の文字=='\n' } cr = false; lineend = true; } else if (lineend) { // 前の文字== '\n' | '\r' lines.Add(i); cr = lineend = text[i] == '\r'; } } this.c_lines = lines.Count; // 文字列の末尾 lines.Add(text.Length); this.i_lines = lines.ToArray(); this.str = text; }
//----------------------------------------------------------------------- // OnDrop //----------------------------------------------------------------------- /// <summary> /// ドロップ処理を実行します。 /// </summary> /// <param name="node">処理対象のノードを指定します。</param> /// <param name="e">ドラッグの情報を指定します。</param> public override void OnDrop(TreeNode node, TreeNodeDragEventArgs e) { TreeTreeNode <T> _dst = node as TreeTreeNode <T>; TreeNodeDDTarget target = this.GetTarget(node, e); switch (e.Effect & this.GetEffect(node, e)) { case Forms::DragDropEffects.Move: { TreeNode node2 = e.Data.GetData("afh.Forms.TreeNode") as TreeNode; if (node2 != null) { this.OnDrop_MoveNode(_dst, node2, target); break; } Gen::List <TreeNode> list = e.Data.GetData("afh.Forms.TreeNode:List") as Gen::List <TreeNode>; if (list != null) { this.OnDrop_MoveList(_dst, list, target); break; } break; } case Forms::DragDropEffects.Link: case Forms::DragDropEffects.Copy: throw new System.NotImplementedException(); default: break; } }
static string ResolveTraversal(string path) { Gen::List <string> list = InternalResolveTraversal(path); if (list.Count == 1) { return(list[0].Length == 0?"/":list[0]); } System.Text.StringBuilder build = new System.Text.StringBuilder(); bool isfirst = true; foreach (string e in list) { if (isfirst) { isfirst = false; } else { build.Append('/'); } build.Append(e); } return(build.ToString()); }
public ProgramSettingData001(ProgramSettingData000 data) { this.accounts = new Gen::List <IFsAccount>(); foreach (IFsAccount acc in data.accounts) { this.accounts.Add(acc); } }
//======================================================== private void parseCommand(ref Gen::List <INode> list) { try{ list.Add(this.ProcessCommand(scanner.CurrentWord, scanner.Value)); }catch (RegexParseException e) { this.scanner.LetterReader.SetError(e.Message, 0, null); } this.scanner.ReadNext(); }
/// <summary> /// path で指定したディレクトリの内容を読み取って、情報を更新します。 /// </summary> /// <param name="rpath">目的のディレクトリを示すパスを指定します。</param> /// <exception cref="Tamir.SharpSsh.jsch.SftpException"> /// 読み取りに失敗した場合に発生します。</exception> Gen::List <FileInfo> UpdateList(string rpath) { // 情報取得 session.Message.Write(1, "$ ls {0}", rpath); java::util.Vector entries; try{ entries = session.Sftp.noglob_ls(rpath); }catch (Tamir.SharpSsh.jsch.SftpException e) { switch ((Unix.SSH_ERROR)e.id) { case mwg.Unix.SSH_ERROR.NO_SUCH_FILE: case mwg.Unix.SSH_ERROR.NO_SUCH_PATH: session.Message.Write(1, "! ls: not found {0}", rpath); ficache.SetList(rpath, null); // "存在しない" return(null); default: throw; } } // 結果登録 string dir = rpath; if (!dir.EndsWith("/")) { dir += "/"; } System.DateTime now = System.DateTime.Now; Gen::List <FileInfo> list = new Gen::List <FileInfo>(); foreach (Tamir.SharpSsh.jsch.ChannelSftp.LsEntry entry in entries) { //string filename=mwg.Unix.UnixPath.QuoteWildcard(entry.getFilename()); string filename = entry.getFilename(); if (filename == ".") { string filepath = rpath; FileInfo info = this.CreateFileInfo(filepath, entry.getAttrs(), now); this.ficache.SetFile(info); } else if (filename == "..") { continue; } else { string filepath = dir + filename; FileInfo info = this.CreateFileInfo(filepath, entry.getAttrs(), now); list.Add(info); } } this.ficache.SetList(rpath, list); return(list); }
public static string GetRelativePathTo(string content, string root) { // 0 canonical // 1 共通部分を削除 // 2 遡って、削除 Gen::List <string> listC = InternalResolveTraversal(content); Gen::List <string> listR = InternalResolveTraversal(root); bool isAbsC = listC.Count > 0 && listC[0].Length == 0; bool isAbsR = listR.Count > 0 && listR[0].Length == 0; if (isAbsC != isAbsR) { return(content); } int ihead = 0; while (ihead < listC.Count && ihead < listR.Count && listC[ihead] == listR[ihead]) { ihead++; } bool isfirst = true; System.Text.StringBuilder build = new System.Text.StringBuilder(); for (int index = ihead; index < listR.Count; index++) { if (isfirst) { isfirst = false; } else { build.Append('/'); } build.Append(".."); } for (int index = ihead; index < listC.Count; index++) { if (isfirst) { isfirst = false; } else { build.Append('/'); } build.Append(listC[index]); } return(build.ToString()); }
private void OnDrop_MoveList(TreeTreeNode <T> _dst, Gen::List <TreeNode> list, TreeNodeDDTarget target) { _todo.TreeNodeDisplayHeight("TreeNodeCollection.Suppress: ノードリストの幾何再計算・再描画を抑止"); _todo.TreeNodeDisplayHeight("target==Child の時は AddRange を利用する様にする?"); using (_dst.Nodes.SuppressLayout()) foreach (TreeNode node3 in list) { this.OnDrop_MoveNode(_dst, node3, target); } }
static string init_GetPrompt(Gen::List <SshUserData> gwchain) { int ilast = gwchain.Count - 1; if (ilast < 0) { throw new System.ArgumentException("gwchain には要素が含まれていません。", "gwchain"); } return(gwchain[ilast].Prompt); }
private static Tree.IExpression[] GetArguments(Gen::List <Tree.IExpression> args_rev) { Tree.IExpression[] args = new Tree.IExpression[args_rev.Count]; for (int iS = args_rev.Count - 1, iD = 0; iS >= 0; iS--, iD++) { args[iD] = args_rev[iS]; } return(args); }
public static Expression operator*(Member m, Expression x) { Gen::List <Member> list = new Gen::List <Member>(); foreach (Member m1 in x.mems) { list.Add(m * m1); } list.Sort(Member.MemberOrderComparer); return(new Expression(list)); }
public void RestartProcess() { if (locked_threads == null) { return; } foreach (Thread thread in this.locked_threads) { thread.Resume(); thread.Dispose(); } locked_threads = null; }
void DiscardOld(System.DateTime referenceTime) { System.DateTime dthresh = referenceTime - TIMEOUT; if (this.oldestInfoTime > dthresh) { return; } lock (sync_root){ System.DateTime oldest = System.DateTime.MaxValue; Gen::List <string> remove_key = new Gen::List <string>(); foreach (Gen::KeyValuePair <string, FileInfo> pair in this.dicattr) { System.DateTime infotime = pair.Value.informationTime; if (infotime < dthresh) { remove_key.Add(pair.Key); } else if (infotime < oldest) { oldest = infotime; } } foreach (string k in remove_key) { this.dicattr.Remove(k); } remove_key.Clear(); foreach (Gen::KeyValuePair <string, DirEntries> pair in this.diclist) { System.DateTime infotime = pair.Value.informationTime; if (infotime < dthresh) { remove_key.Add(pair.Key); } else if (infotime < oldest) { oldest = infotime; } } foreach (string k in remove_key) { this.diclist.Remove(k); } this.oldestInfoTime = oldest; } }
//================================================= // Preprocess Directives //================================================= private string PreprocessDirectives(string text) { Gen::Dictionary <int, string> errors = new Gen::Dictionary <int, string>(); Gen::List <DefineMacro> defs = new Gen::List <DefineMacro>(); DefineMacro def; string text2 = reg_directive.Replace(text, delegate(System.Text.RegularExpressions.Match m){ if (m.Groups["nspace"].Success) { if (this.@namespace != null) { errors.Add(m.Index, "名前空間を複数指定する事は出来ません。"); } this.@namespace = m.Groups["nspace"].Value; } else if (m.Groups["class"].Success) { if (this.classname != null) { errors.Add(m.Index, "クラス名を複数指定する事は出来ません。"); } this.classname = m.Groups["class"].Value; } else if (m.Groups["defname"].Success) { def = new DefineMacro(); def.name = m.Groups["defname"].Value; def.Content = m.Groups["defcontent"].Value; // 引数リスト System.Text.RegularExpressions.CaptureCollection capts = m.Groups["defarg"].Captures; int iM = capts.Count; def.args = new string[capts.Count]; for (int i = 0; i < iM; i++) { def.args[i] = capts[i].Value; } defs.Add(def); } return(reg_remove.Replace(m.Value, "")); }); foreach (DefineMacro define in defs) { define.Apply(ref text2); } return(text2); }
//======================================================== /// <summary> /// '|' で区切られた候補達を読み取ります。 /// </summary> /// <returns>読み取って出来たノードを返します。有効な正規表現指定が見つからなかった場合には null を返します。</returns> private INode Read() { Gen::List <INode> nodes = new Gen::List <INode>(); while (true) { switch (this.scanner.CurrentType.value) { case WordType.vInvalid: goto ED_LOOP; case WordType.vOperator: if (scanner.CurrentWord == ")") { goto ED_LOOP; } else if (scanner.CurrentWord == "|") { this.scanner.ReadNext(); goto default; } else { goto default; } default: INode node = this.ReadSequence(); if (node == null) { scanner.LetterReader.SetError("正規表現要素が一つもありません。", 0, null); break; } nodes.Add(node); break; } } ED_LOOP: if (nodes.Count == 0) { return(null); } if (nodes.Count == 1) { return(nodes[0]); } return(new OrNode(nodes.ToArray())); }
public void StopProcess() { if (locked_threads != null) { return; } locked_threads = new System.Collections.Generic.List <Thread>(); foreach (ProcessThread th in this.process.Threads) { Thread thread = new Thread(th.Id); thread.Suspend(); locked_threads.Add(thread); } }
internal Group(TCapture parent, int index) { this.parent = parent; this.name = null; if (index == 0) { // 自分自身だけに一致 this.cache = new Gen::List <TCapture>(1); this.cache.Add(this.parent); } else { this.node = GetIndexedNode(ref index, parent.Range.Node); } }
//-------------------------------------------------------------------------- public bool TryGetList(string path, out Gen::List <SftpFileInfo> result) { this.DiscardOld(); lsres_t value; if (diclist.TryGetValue(path, out value)) { result = value.result; return(true); } else { result = null; return(false); } }
public string[] splitModifiers(string mod) { Gen::List <string> list = new Gen::List <string>(); string[] cands = mod.Split('.'); string cand; for (int i = 0; i < cands.Length; i++) { cand = cands[i].Trim(); if (cand != "") { list.Add(cand); } } return(list.ToArray()); }
public static Expression operator-(Expression l, Expression r) { Gen::List <Member> mems = new Gen::List <Member>(); int il = 0, ilM = l.mems.Count; int ir = 0, irM = r.mems.Count; while (il < ilM && ir < irM) { int val = Member.MemberOrder(l.mems[il], r.mems[ir]); if (val < 0) { mems.Add(l.mems[il++]); } else if (val > 0) { mems.Add(-r.mems[ir++]); } else { Member m = l.mems[il++] - r.mems[ir++]; if (!m.IsZero) { mems.Add(m); } } } if (il < ilM) { do { mems.Add(l.mems[il++]); }while(il < ilM); } else if (ir < irM) { do { mems.Add(-r.mems[ir++]); }while(ir < irM); } return(new Expression(mems)); }
//=========================================================== // 乗除 //=========================================================== public static Member operator*(Member l, Member r) { Gen::List <Variable> vars = new Gen::List <Variable>(); int il = 0, ilM = l.vars.Length; int ir = 0, irM = r.vars.Length; while (il < ilM && ir < irM) { int val = Variable.VariableOrderWithoutExp(l.vars[il], r.vars[ir]); if (val < 0) { vars.Add(l.vars[il++]); } else if (val > 0) { vars.Add(r.vars[ir++]); } else { Variable v = l.vars[il++] * r.vars[ir++]; if (!v.IsConstant) { vars.Add(v); } } } if (il < ilM) { do { vars.Add(l.vars[il++]); }while(il < ilM); } else if (ir < irM) { do { vars.Add(r.vars[ir++]); }while(ir < irM); } return(new Member(l.factor * r.factor, vars.ToArray())); }
/// <summary> /// 指定した file-directory 内の画像をこの ImageDirectory に登録します。 /// </summary> /// <param name="dirpath">登録する画像を含んでいるディレクトリへの path を指定します。</param> public void AddFilesFromDirectory(string dirpath) { if (!System.IO.Directory.Exists(dirpath)) { return; } System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(dirpath); Gen::List <string> filepaths = new Gen::List <string>(); foreach (System.IO.FileInfo file in dir.GetFiles()) { if (!exts.Contains(file.Extension.ToLower())) { continue; } filepaths.Add(file.FullName); } if (filepaths.Count == 0) { return; } afh.Forms.ProgressDialog progress = new afh.Forms.ProgressDialog(); progress.Title = "画像を読込中 ..."; progress.ProgressMax = filepaths.Count; progress.Show(); // 読込 foreach (string path in filepaths) { try{ progress.Description = "画像 " + path + " を読み込んでいます..."; this.AddFile(path); progress.Progress++; if (progress.IsCanceled) { break; } }catch (System.Exception e) { afh.File.__dll__.log.WriteError(e, path + " の読込に失敗しました。"); } } progress.Close(); }
static ConnectionInfo CreateConnectionInfo(SshUserData data) { // create Authentication methods Gen::List <AuthenticationMethod> auth = new Gen::List <AuthenticationMethod>(); if (data.pass != null && data.pass != "") { // Password based Authentication auth.Add(new PasswordAuthenticationMethod(data.user, data.pass)); } if (data.useIdentityFile && data.idtt != "") { // Key Based Authentication (using keys in OpenSSH Format) auth.Add(new PrivateKeyAuthenticationMethod(data.user, new PrivateKeyFile[] { new PrivateKeyFile(data.idtt, data.psph) })); } return(new ConnectionInfo(data.host, data.port, data.user, auth.ToArray())); }
private Forms::DragDropEffects GetEffect_List(TreeTreeNode <T> _dst, Gen::List <TreeNode> list, Forms::DragDropEffects mask) { foreach (TreeNode node2 in list) { TreeTreeNode <T> _src = node2 as TreeTreeNode <T>; if (_src == null) { return(Forms::DragDropEffects.None); } mask &= _src.DragEffectToTreeNode; if (_src.IsDescendant(_dst) || _src == _dst) { mask &= ~Forms::DragDropEffects.Move; } } return(mask); }
private static string chkListBehaviour_List2Str(Gen::List <int> list) { System.Text.StringBuilder b = new System.Text.StringBuilder(); bool isfirst = true; foreach (int val in list) { if (isfirst) { isfirst = false; } else { b.Append(" "); } b.Append(val); } return(b.ToString()); }
/// <summary> /// 指定したパスを結合し、.. や . 等の指定を含む場合にはそれらを解決します。 /// </summary> /// <param name="path1">先に来るパスを指定します。</param> /// <param name="path2">後にくるパスを指定します。</param> /// <returns>結合した後のパスを返します。</returns> public static string Combine(string path1, string path2) { string path0 = System.IO.Path.Combine(path1, path2); if (path0.IndexOf("..") < 0) { return(path0); } //-- 正規化 string[] paths = path0.TrimEnd('\\', '/').Split('\\', '/'); Gen::List <string> paths2 = new Gen::List <string>(); System.Text.StringBuilder r = new System.Text.StringBuilder(); for (int i = 0; i < paths.Length; i++) { if (paths[i] == "..") { if (paths2.Count == 0) { r.Append(@"..\"); } else { paths2.RemoveAt(paths2.Count - 1); } } else if (paths[i] != ".") { paths2.Add(paths[i]); } } foreach (string x in paths2.ToArray()) { r.Append(x); r.Append(@"\"); } ; string r2 = r.ToString(); return(r2 == ""?".":r2.TrimEnd('\\')); }
//========================================================================== // ISerializable //========================================================================== SftpAccountGw(Ser::SerializationInfo info, Ser::StreamingContext context) { this.name = info.GetString("name"); this.gwchain = (Gen::List <SshUserData>)info.GetValue("gwchain", typeof(Gen::List <SshUserData>)); SerializationInfoReader reader = new SerializationInfoReader(info); reader.GetValue("offline", out this.s_offline, false); reader.GetValue("rootdir", out this.rootdir, "."); reader.GetValue("s_readonly", out this.s_readonly, false); reader.GetValue("s_reconnect_count", out this.s_reconnect_count, 1); reader.GetValue("s_discon_interval", out this.s_discon_interval, 300); reader.GetValue("s_beat_interval", out this.s_beat_interval, 60); int symlink; if (reader.GetValue("symlink", out symlink)) { this.symlink = (SftpSymlink)symlink; } reader.GetValue("s_enabled", out this.s_enabled, true); }
private void btnNext_Click(object sender, System.EventArgs e) { if (!System.IO.Directory.Exists(this.txt_Dir.Text)) { System.Windows.Forms.MessageBox.Show("指定したディレクトリは有効なディレクトリではありません。"); return; } EncInfo info = this.comboBox1.SelectedItem as EncInfo; if (info == null) { System.Windows.Forms.MessageBox.Show("文字コードが正しく選択されていません。"); return; } this.encoding = info.GetEncoding(); this.listView1.Items.Clear(); this.candidates = new Gen::List <RenameItem>(); search_dir(new System.IO.DirectoryInfo(this.txt_Dir.Text)); this.listView1.Items.AddRange(this.candidates.ToArray()); }
public static void Animate(Gdi::Image image, System.EventHandler onFrameChangedHandler) { if (image == null) { return; } ImageInfo item = null; lock (image) item = new ImageInfo(image); StopAnimate(image, onFrameChangedHandler); WriterLock w_lock; using (new WriterLockWait()) w_lock = new WriterLock(rwImgListLock); using (w_lock){ if (!item.animated) { return; } if (imageInfoList == null) { imageInfoList = new Gen::List <ImageInfo>(); } item.onFrameChangedHandler = onFrameChangedHandler; imageInfoList.Add(item); if (animationThread == null) { animationThread = new Thr::Thread(new Thr::ThreadStart(ImageAnimator.AnimateImages50ms)); animationThread.Name = typeof(ImageAnimator).Name; animationThread.IsBackground = true; animationThread.Start(); } } }
byte[] ZipDeflate(byte[] str,int level) { int i,j; deflate_data=str; deflate_pos=0; deflate_start(level); byte[] buff=new byte[1024]; Gen::List<byte> @out=new Gen::List<byte>(); while((i=deflate_internal(buff,0,buff.Length))>0){ for(j=0;j<i;j++)@out.Add(buff[j]); } deflate_data=null;// G.C. return @out.ToArray(); }
public static string ProcessSource(string input,Argument _args){ string output=input; Argument args=_args; string dirname=System.IO.Path.GetDirectoryName(args.OutputFile); // directives の読み取り Gen::Dictionary<string,string> tokenmap=new Gen::Dictionary<string,string>(); Gen::List<ReplaceData> replaces=new Gen::List<ReplaceData>(); output=reg_gzjs_directive.Replace(output,delegate(Rgx::Match m){ // 先頭以外に改行が入っている物は無効 if(0<m.Value.IndexOfAny("\r\n".ToCharArray()))return m.Value; switch(m.Groups["dir"].Value){ case "outfile": args.OutputFile=System.IO.Path.Combine( System.IO.Path.GetDirectoryName(args.OutputFile), ReadArg(m.Groups["arg1"]) ); if(args.Verbose) args.WriteLine("#> output-file was set to '"+args.OutputFile+"'"); return "\n"; case "tokenmap":{ string before=ReadArg(m.Groups["arg1"]); string after=ReadArg(m.Groups["arg2"]); tokenmap[before]=after; if(args.Verbose) args.WriteLine("#> token-mapping registered: "+before+" -> "+after+""); return "\n"; } case "replace":{ string before=ReadArg(m.Groups["arg1"]); string after=ReadArg(m.Groups["arg2"]); replaces.Add(new ReplaceData(before,after)); if(args.Verbose) args.WriteLine("#> replace registered: "+before+" -> "+after+""); return "\n"; } case "include":{ if(args.Verbose) args.WriteLine("#gzjs-include"); return Program.Include(ReadArg(m.Groups["arg1"]),args)??m.Value; } case "option":{ string op=ReadArg(m.Groups["arg1"]); if(!args.ReadOption(op)){ args.WriteLine("#gzjs-option > '{0}' は認識できない option です",op); return m.Value; } return "\n"; } default: return m.Value; } }); // コメント空白類の削除 if(args.CutComment) output=RegExp.CutComment(output); // token 置き換え if(tokenmap.Count>0){ string rex=null; foreach(string token in tokenmap.Keys){ if(rex==null)rex=token;else rex+="|"+token; } rex=@"\b(?:"+rex+@")\b"; output=new Rgx::Regex(rex).Replace(output,delegate(Rgx::Match m){ return tokenmap[m.Value]; }); } // #gzjs-replace 実行 foreach(ReplaceData r in replaces) output=r.Replace(output); return output; }