-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileManager.cs
More file actions
147 lines (120 loc) · 3.93 KB
/
Copy pathFileManager.cs
File metadata and controls
147 lines (120 loc) · 3.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/*
* Copyright (C), 2007, Mathieu Kooiman < xdc@scriptorama.nl>
* $Id: FileManager.cs 14 2007-04-29 17:32:40Z mathieuk $
*
* This file is part of XDebugClient.
*
* XDebugClient is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
* XDebugClient is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with XDebugClient; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
using System;
using System.Collections.Generic;
using System.Text;
using xdc.XDebug;
using xdc.Forms;
using System.Windows.Forms;
namespace xdc.GUI
{
struct OpenFileStruct
{
public string localFilename;
public string remoteFilename;
public SourceFileForm form;
}
class DirectoryRewrite
{
public string remotePath;
public string localPath;
}
/// <summary>
/// Keeps a list of Forms and their remote plus local filenames.
/// </summary>
class FileManager
{
private Dictionary<string, OpenFileStruct> _openFiles;
public bool HasOpenFiles
{
get
{
return _openFiles.Count > 0;
}
}
public Dictionary<string, OpenFileStruct> Forms
{
get
{
return _openFiles;
}
}
public FileManager()
{
_openFiles = new Dictionary<string, OpenFileStruct>();
}
public SourceFileForm getFirstForm()
{
if (_openFiles.Keys.Count > 0)
{
System.Collections.Generic.Dictionary<string, OpenFileStruct>.Enumerator al = _openFiles.GetEnumerator();
if (al.MoveNext())
{
return al.Current.Value.form;
}
}
return
null;
}
public void Add(string actualFilename, string localFilename, SourceFileForm form)
{
OpenFileStruct file = new OpenFileStruct();
file.localFilename = localFilename;
file.remoteFilename = actualFilename;
file.form = form;
_openFiles.Add(file.localFilename, file);
}
public void Remove(string filename)
{
if (_openFiles.ContainsKey(filename))
{
_openFiles.Remove(filename);
}
}
public string GetLocalFilename(string RemoteFilename)
{
foreach (OpenFileStruct file in _openFiles.Values)
{
if (file.remoteFilename == RemoteFilename)
{
return file.localFilename;
}
}
return "";
}
public SourceFileForm getFormByLocalFilename(string filename)
{
if (_openFiles.ContainsKey(filename))
return _openFiles[filename].form;
return null;
}
public SourceFileForm getFormByRemoteFilename(string filename)
{
foreach (OpenFileStruct file in _openFiles.Values)
{
if (file.remoteFilename == filename)
{
return file.form;
}
}
return null;
}
}
}