-
Notifications
You must be signed in to change notification settings - Fork 0
/
BlogFileSystem.html
294 lines (269 loc) · 14.3 KB
/
BlogFileSystem.html
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
<!DOCTYPE html>
<html>
<!--
BlogFileSystem.html
-->
<head>
<title>Blog FileSystem</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- <link rel="icon" type="image/x-icon" href="./images/favicon.ico" /> -->
<link rel="stylesheet" href="css/StylesPhoto.css" />
<link rel="stylesheet" href="css/StylesSizerComp.css" />
<!-- PageFrame infrastructure -->
<link rel="stylesheet" href="css/StylesPageFrameDefaults.css" />
<link rel="stylesheet" href="css/StylesPageFrameStructure.css" />
<link rel="stylesheet" href="css/StylesPageFrameMenus.css" />
<link rel="stylesheet" href="css/StylesPageFrameThemePython.css" />
<link rel="stylesheet" href="css/StylesWebComponents.css" />
<script src="js/ScriptsWebComponents.js"></script>
<!--<script src="js/ScriptsPageFrameDefaults.js"></script>-->
<script src="js/ScriptsPageFramePosts.js"></script>
<script src="js/ScriptsPageFramePagesPosts.js"></script>
<script src="js/ScriptsPageFrameKeyboard.js"></script>
<!-- <script src="js/ScriptsSizerComp.js"></script> -->
<!-- No need for Pages script for pages with no next or prev pages -->
<!--<script src="js/ScriptsPageFramePages.js"></script>-->
<!-- <script src="js/ScriptsTemplate.js"></script>
<link rel="stylesheet" href="css/StylesTemplate.css" /> -->
<style>
h3 {
margin-top: 1.5em;
}
#subtitle {
margin-top: 0.4em;
margin-bottom: 0.3em;
}
#github header summary {
border: 1px solid var(--light);
}
#github summary {
padding-right: 2em;
}
/* #github .menuHead {
margin:0em -0.25em 0.0em -0.25em;
padding:0.25em 0.5em;
} */
</style>
<script>
function load() {
initialize();
//loadif();
}
</script>
<style>
#github note {
display: block;
width:max-content;
border:1px solid red;
padding:0.5em 1.0em;
margin:0.5em 0em;
}
#github .bargraph {
border: 1px solid var(--dark);
/* background-color: #bbb; */
padding: 0.1em 0.5em;
font-size:0.9em;
}
#github table {
border:2px solid var(--dark);
}
#github table td {
padding:0.25em 1.0em;
border:none;
}
body {
user-select:none;
}
</style>
<script>
function clickstat() {
// prevent parent click event handling
event.stopImmediatePropagation();
}
</script>
</head>
<body id="github" onload="load()" style="position:relative;">
<a id="Next" href="Post_DistinguishedRust.html">Next</a>
<a id="Prev" href="BlogGraph.html">Prev</a>
<page-frame>
<frame-header>
<nav id="navbar"></nav>
</frame-header>
<main id="main">
<div id="about" onclick="this.style.display = 'none'">about</div>
<div id="page">Blog: FileSystem</div>
<div id="modified">11/29/2024</div>
<div id="hlp"></div>
<a id="top"></a>
<content style="height:100vh; position:relative;">
<header style="cursor:pointer;" onclick="loadif()">
<!-- <a target="_blank" class="repoLink" href="https://github.com/JimFawcett">github Repositories</a> -->
<hgroup id="pagetitle" style="border: 2px solid var(--dark);">
<h1 id="title">Blog: File System</h1>
<h3 class="indent" id="subtitle">
directory, path, file, fileinfo, block
</h3>
</hgroup>
<!-- <img style="width:100%; margin:-0.1em 0em; border:2px solid var(--dark); padding:0.5em; background-color:var(--light);" src="Pictures/officestrip3a.svg" /> -->
<div class="darkItem" onclick="loadif()" style="cursor:pointer; position:relative; padding:0.0em 0em 0.25em 0em; margin-top:-0.50em; border:2px solid var(--dark);">
<a class="repoLinks" target="_blank" href="https://github.com/JimFawcett" style="color:var(--atten); margin-left:1.5em;">About</a>
<div style="font-size:0.9em; position:absolute; top:0.1em; right:1.5em;">click to toggle Site Explorer</div>
<div style="height:0.5em;"></div>
</div>
</header>
<div style="border:2px solid red; padding:0.25em 1.0em; margin: 0.75em 0em; width:max-content; max-width:calc(100vw - 8em);">
Note: This post was written before C++17 released the std::filesystem library.
</div>
<h3>Initial Thoughts:</h3>
<t-b>
C++11 has a lot of useful features, many <a target="_blank" href="http://herbsutter.com/elements-of-modern-c-style/">new to the latest 2011 standard</a>, e.g.,
range-based for loop, uniform initialization, type inference with auto, new smart pointers, lambda functions, move constructors and assignments, etc.
One of the things that was discussed but not adopted was the addition of file and directory management facilities in the standard C++ library.
</t-b>
<t-b>
Projects for CSE687 - Object Oriented Design and CSE775 - Distributed Objects often require us to find, using C++ code, files on specific directory paths
that match a specified pattern. So not having file and directory management libraries means we get to write a lot of low-level code using
platform specific APIs or interoperate with code developed in languages that do provide that library support, like C#.
While that is not that difficult to do, it would be very convenient to have native C++ libraries that provide such support.
</t-b>
<h3 id="background">Background:</h3>
<t-b>
CSE775 - Distributed Objects is concerned with system programming for both Windows and Linux platforms. The first assigned project requires
development of components using the Microsoft Component Object Model (COM) on Windows and components on Linux that use the same model,
e.g., code accessed through interfaces and object factories and that uses reference counting management of object life-time.
</t-b>
<t-b>
For the second major project each student selects from a list of <a target="_blank" href="../CSE775/lectures/CSE775Projects.htm">suggestions</a>. Most of these projects
explore some interesting platfrom that will require student research to learn a new, for them, technology. They then propose development of
an application, they will develop, that illustrates how the technology works and will be technically interesting for the rest of the class.
Many of these projects
are expected to create applications that run on both Windows and Linux or that have components that interoperate across these platforms.
</t-b>
<h3 id="core_idea">Core Idea:</h3>
<t-b>
In order to support cross-platform development we have been working on libraries that provide access to system artifacts: files, directories,
threads and locks<sup>1</sup>, process management, and socket-based communication. The idea is for the libraries to host the same interfaces on
both platforms while using the underlying platform APIs<sup>2</sup>. That way we can build applications out of code common to both platforms
that use these Windows or Linux libraries without change.
</t-b>
<t-b>Building common Graphical User Interfaces (GUI)s provide an interesting challenge which we will discuss in a future Blog page.</t-b>
<div class="right">
<photosizer-block src="Pictures/Blog.FileSystem.png" width="350" class="photoSizerBlock">
<span style="font-family:'Comic Sans MS';">Figure 1. - File System Classes</span>
</photosizer-block>
</div>
<div class="right clear">
<photosizer-block src="Pictures/Blog.FileSystemOutput.png" width="350" class="photoSizerBlock">
<span style="font-family:'Comic Sans MS';">Figure 2. - Demonstration Output</span>
</photosizer-block>
</div>
<!-- <div style="width:calc(100vw - 9rem);">
<div class="right clear photo" style="margin: 10px; padding: 10px;">
<img name="filesys" width="600" onmouseover="filesys.width='900'" onmouseout="filesys.width='600'" src="Pictures/Blog.FileSystem.png" />
<div class="center">Figure 1 - File System Classes</div>
</div>
</div> -->
<h3 id="design">Design:</h3>
<t-b>
Here, we focus on our FileSystem library that supports operations on the file systems of either Windows or Linux
through the same set of interfaces.
</t-b>
<t-b>
The FileSystem library contains four main classes: Directory, Path, FileInfo, and File, with another public helper class Block and
private helper class FileSystemSearch.
The main classes are modeled after similar classes in the .Net System.IO namespace.
</t-b>
<t-b>
Directory is composed of static member functions for manipulating directories and files. For example, Directory::getFiles(...) returns a std::vector<string>
containing the names of files on a specified path that match a specified pattern.
</t-b>
<t-b>
Path supports parsing fully qualified file specifications into path, file name, and extension and composing those parts into a file specification.
Its function getFullFileSpec(...) supports converting a relative path into an absolute path.
</t-b>
<t-b>
The FileInfo class provides facilities for retrieving directory properties about a directory entry, like date of last modification, size, and whether
it is a file or directory. The class also supports comparing properties of two specified files.
</t-b>
<t-b>The File class supports opening, reading lines or blocks of bytes, writing lines or blocks of bytes, and testing FileStream state.</t-b>
<t-b>
Finally, the Block class wraps an array of bytes for read and write operations on instances of the File class. Blocks are most useful for file transfers with
chunking - breaking a file into pieces for transmission over a socket-based channel.
</t-b>
<!-- <div style="width:calc(100vw - 9rem);">
<div class="right clear photo" style="margin: 10px; padding: 10px;">
<img name="filesysOut" width="600" onmouseover="filesysOut.width='900'" onmouseout="filesysOut.width='600'" src="Pictures/Blog.FileSystemOutput.png" />
<div class="center">Figure 2 - File System Output</div>
</div>
</div> -->
<h3 id="output">Typical Output:</h3>
<t-b>Demo output is presented in Figure 2, which shows construction test output for some of the main classes.</t-b>
<h3 id="code">Source Code:</h3>
<t-b>
This FileSystem library is written in C++ using Visual Studio 2013 and compiles and runs using Visual Studio 2013 as well.
You will find the code here:
<div class="indent" style="margin: 10px;">
<a target="_blank" href="../CoreTechnologies/Cpp/code/FileSystem-Windows">FileSystem- Windows library</a>
</div>
</t-b>
<t-b>This code bears a copyright © that grants all rights to users except the right to publish and requires retention of the copyright notice.</t-b>
<h3 id="conclusions">Conclusions:</h3>
<t-b>
The C++ FileSystem library has proven to be almost as easy to use as its .Net counterpart System.IO. The library has been used by several classes
to support their project work and found to be sufficient for most project needs.
</t-b>
<div class="footnote">
<hr />
<ol>
<li>
C++ now supports, under the C++11 standard, threads, locks, and atomics as part of the standard C++ library. Thus we no longer need to
maintain the thread and locks classes we've used before the new standard was implemented for the compilers we use, e.g., Visual Studio
and GCC.
</li>
<li>
That is, of course, exactly what the C++ standard library does. We are simply augmenting the standard library using the same approach.
</li>
</ol>
</div>
<div style="height:1.0em;"></div>
<t-b>
<div style="width:calc(100vw - 9rem);"><img class="photo" src="Pictures/QuadStrip.jpg" alt="Newhouse" style="width:100%;" /></div>
</t-b>
<div style="height:1.0em;"></div>
<a id="bottom"></a>
</content>
<page-TOC id="pages" style="display:none;">
</page-TOC>
<page-sections id="sections" style="display:none;">
<menu-elem style="width:0.0em"> </menu-elem>
<menu-elem class="secElem"><a href="#bottom">bottom</a></menu-elem>
<menu-elem class="secElem"><a href="#conclusions">conclusions</a></menu-elem>
<menu-elem class="secElem"><a href="#code">code</a></menu-elem>
<menu-elem class="secElem"><a href="#output">output</a></menu-elem>
<menu-elem class="secElem"><a href="#design">design</a></menu-elem>
<menu-elem class="secElem"><a href="#core_idea">core_idea</a></menu-elem>
<menu-elem class="secElem"><a href="#background">background</a></menu-elem>
<menu-elem class="secElem"><a href="#top">top</a></menu-elem>
<div class='darkItem popupHeader' style="padding:0.25em 2.0em;" onclick="this.parentElement.style.display='none'">Sections</div>
</page-sections>
</main>
<frame-footer>
<menu-item style="width:2.0em;"> </menu-item>
<menu-elem id="nextLink2" onclick="bottomMenu.next()">Next</menu-elem>
<menu-elem id="prevLink2" onclick="bottomMenu.prev()">Prev</menu-elem>
<menu-elem id="pgbtn" onclick="bottomMenu.pages()">Pages</menu-elem>
<menu-elem onclick="bottomMenu.sections()">Sections</menu-elem>
<menu-elem onclick="bottomMenu.about()">About</menu-elem>
<menu-elem id="kysbtn" onclick="storyHlpMenu.keys()">Keys</menu-elem>
<menu-elem style="margin-right:1em">
<span id="loc" style="display:inline-block; font-weight:normal"></span>
</menu-elem>
</frame-footer>
</page-frame>
<script>
let loc = document.getElementById("loc");
let fn = window.location.href.split(/\/|\\/).pop();
loc.innerHTML = fn + ":";
</script>
</body>
</html>