-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathSystem.IO.debug.js
More file actions
701 lines (675 loc) · 25.8 KB
/
System.IO.debug.js
File metadata and controls
701 lines (675 loc) · 25.8 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
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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
//=============================================================================
// Jocys.com JavaScript.NET Classes (In C# Object Oriented Style)
// Created by Evaldas Jocys <evaldas@jocys.com>
//=============================================================================
/// <reference path="System.debug.js" />
//=============================================================================
// Namespaces
//-----------------------------------------------------------------------------
// <PropertyGroup>
// <RootNamespace>System.IO</RootNamespace>
// <PropertyGroup>
//-----------------------------------------------------------------------------
System.IO = System.IO ? System.IO : {};
System.Type.RegisterNamespace("System.IO");
//=============================================================================
System.IO.Directory = function () { };
System.Type.RegisterClass("System.IO.Directory");
System.IO.Directory.CreateDirectory = function (path) {
/// <summary>
/// Creates all directories and subdirectories as specified by path.
/// </summary>
/// <param type="String" type="path">The directory path to create.</param>
/// <returns type"">A folder info as specified by path.</returns>
/// <remarks>
/// ASP GetFolder Method
/// http://msdn2.microsoft.com/en-us/library/f1xtf7ta.aspx
/// http://msdn2.microsoft.com/en-us/library/bkx696eh.aspx
/// File Object Properties:
/// Attributes, DateCreated, DateLastAccessed, DateLastModified
/// Drive, Name, ParentFolder, Path, ShortName, ShortPath, Size, Type
/// </remarks>
// Create object to manipulate folders and files.
var folderInfo = null;
var fso = new ActiveXObject("Scripting.FileSystemObject");
var pathPhysical = new String(path);
// If folder path is not physical then...
if (pathPhysical.indexOf(":") === -1) {
// Convert path to Physical.
pathPhysical = Server.MapPath(path);
}
// Check if folder exist and create it if not.
var arrPath = new Array;
var regex = new RegExp("\\\\", "g");
arrPath = pathPhysical.split(regex);
var pathTemp = "";
// Route thru folders of path.
for (var i = 0; i < arrPath.length; i++) {
// Get folder name;
var folderName = arrPath[i];
if (i > 0) pathTemp += "\\";
pathTemp += folderName;
// If this is not root folder (drive letter) then...
if (i > 0) {
// If this folder does not exist then...
if (!fso.FolderExists(pathTemp)) {
// Create this folder.
Trace.Write("Create folder: " + pathTemp);
try {
fso.CreateFolder(pathTemp);
folderInfo = fso.GetFolder(pathTemp);
} catch (ex) {
//Trace.Write("Failed to create folder.");
}
}
}
}
return folderInfo;
};
System.IO.Directory.GetItems = function (path, searchPattern, typeIsFiles) {
var fso = new ActiveXObject("Scripting.FileSystemObject");
var f = fso.GetFolder(path);
var fc = new Enumerator(typeIsFiles ? f.Files : f.SubFolders);
//Trace.Write(f.Name);
var items = [];
var pattern = "";
pattern = searchPattern ? searchPattern : ".*";
var regExp = new RegExp(pattern);
var name = "";
for (; !fc.atEnd(); fc.moveNext()) {
// Get name from file object;
var item = fc.item();
var isMatch = item.Name.match(regExp) !== null;
if (isMatch) items.push(item);
}
return items;
};
System.IO.Directory.GetFiles = function (path, searchPattern) {
/// <summary>
/// Returns the names of files in the specified directory that match the specified
/// search pattern.
/// </summary>
/// <param type="String" name="path">The directory to search.</param>
/// <param type="String" name="path">The search string (Regular Expression) to match against the names of files in path.</param>
/// <returns type="String[]">
/// A String array containing the names of files in the specified directory that
/// match the specified search pattern. File names include the full path.
/// </returns>
/// <remarks>
/// http://msdn2.microsoft.com/en-us/library/hww8txat.aspx
/// </remarks>
return System.IO.Directory.GetItems(path, searchPattern, true);
};
System.IO.Directory.GetDirectories = function (path, searchPattern) {
/// <summary>
/// Returns the names of directories in the specified directory that match the specified
/// search pattern.
/// </summary>
return System.IO.Directory.GetItems(path, searchPattern, false);
};
//=============================================================================
// Namespaces
//-----------------------------------------------------------------------------
System.IO.File = function () { };
System.Type.RegisterClass("System.IO.File");
System.IO.File.ReadAllText = function (path) {
/// <summary>
/// Opens a text file, reads all lines of the file, and then closes the file.
/// </summary>
/// <param name="path">The file to open for reading.</param>
/// <returns>A string array containing all lines of the file.</returns>
var useScripting = true;
if (useScripting) {
var ForReading = 1, ForWriting = 2, ForAppending = 8;
var TristateUseDefault = -2; // Opens the file using the system default.
var TristateTrue = -1; // Opens the file as Unicode.
var TristateFalse = 0; // Opens the file as ASCII.
var fdo = new ActiveXObject("Scripting.FileSystemObject");
var textStream = fso.OpenTextFile(path, ForReading);
var content = "";
content = textStream.ReadAll();
textStream.Close();
textStream = null;
return content;
} else {
// Read Binary.
var adTypeBinary = 1, adTypeText = 2, adSaveCreateOverWrite = 2;
// Create Stream object.
var binaryStream = Server.CreateObject("ADODB.Stream");
// Specify stream type - we want To get binary data.
binaryStream.Type = adTypeBinary;
// Open the stream.
binaryStream.Open();
// Load the file data from disk To stream object.
binaryStream.LoadFromFile(path);
// Open the stream And get binary data from the object.
var results = binaryStream.Read();
binaryStream = null;
return results;
}
};
System.IO.File.WriteAllText = function (path, contents, encoding) {
/// <summary>
/// Creates a new file, writes the specified string array to the file using the
/// specified encoding, and then closes the file. If the target file already
/// exists, it is overwritten.
/// </summary>
/// <param type="String" name="path">The file to write to.</param>
/// <param type="String" name="contents">The string to write to the file.</param>
/// <param type="String" name="encoding">An encoding (CharSet) to apply.</param>
/// <returns>void</returns>
// If type of contents is String then...
if (typeof contents === "string") {
var ForReading = 1, ForWriting = 2, ForAppending = 8;
var fileSystem = new ActiveXObject("Scripting.FileSystemObject");
var textStream = fileSystem.CreateTextFile(path);
textStream.Write(contents);
textStream.Close();
textStream = null;
} else {
var adTypeBinary = 1, adTypeText = 2, adSaveCreateOverWrite = 2;
// Create Stream object
var binaryStream = Server.CreateObject("ADODB.Stream");
// Specify stream type - we want To save text/string data.
binaryStream.Type = adTypeBinary;
// Specify charset For the source text (unicode) data.
if (encoding !== null) binaryStream.CharSet = encoding;
// Open the stream.
binaryStream.Open();
// Write binary data To the object.
try { binaryStream.Write(contents); } catch (ex) { /* */ }
// Save binary data To disk.
//Response.Write("valFilePath = "+valFilePath+"<br />");
binaryStream.SaveToFile(path, adSaveCreateOverWrite);
binaryStream = null;
}
};
System.IO.File.Delete = function (path, force) {
/// <summary>
/// Deletes the specified file.
/// </summary>
/// <param type="String" name="path">The name of the file to be deleted.</param>
/// <returns>void</returns>
var fso = new ActiveXObject("Scripting.FileSystemObject");
force = force === true;
return fso.DeleteFile(path, force);
};
System.IO.File.Exists = function (path) {
/// <summary>
/// Determines whether the specified file exists.
/// </summary>
/// <param name="path">The file to check.</param>
/// <returns>True if file exists; otherwise false.</returns>
var fso = new ActiveXObject("Scripting.FileSystemObject");
return fso.FileExists(path);
};
System.IO.File.Move = function (sourceFileName, destFileName) {
/// <summary>
/// Moves a specified file to a new location, providing the option to specify
/// a new file name.
/// </summary>
/// <param type="String" name="sourceFileName">The name of the file to move.</param>
/// <param type="String" name="destFileName">The new path for the file.</param>
/// <returns>void</returns>
var fso = new ActiveXObject("Scripting.FileSystemObject");
return fso.MoveFile(sourceFileName, destFileName);
};
//=============================================================================
// Path
//-----------------------------------------------------------------------------
System.IO.Path = function () { };
System.Type.RegisterClass("System.IO.Path");
System.IO.Path = function () {
/// <summary>
/// Performs operations on System.String instances that contain file or directory
/// path information. These operations are performed in a cross-platform manner.
/// </summary>
/// <remarks>
/// Converted from C# System.IO.Path.
/// </remarks>
//---------------------------------------------------------
// Declare public properties
this.AltDirectorySeparatorChar = '/';
this.DirectorySeparatorChar = '\\';
this.ERROR_SUCCESS = 0;
this.InternalInvalidPathChars = ['"', '<', '>', '|', '\0', '\b', '\x0010', '\x0011', '\x0012', '\x0014', '\x0015', '\x0016', '\x0017', '\x0018', '\x0019'];
this.InvalidPathChars = ['"', '<', '>', '|', '\0', '\b', '\x0010', '\x0011', '\x0012', '\x0014', '\x0015', '\x0016', '\x0017', '\x0018', '\x0019'];
this.MAX_DIRECTORY_PATH = 0xf8;
this.MAX_PATH = 260;
this.PathSeparator = ';';
this.VolumeSeparatorChar = ':';
//---------------------------------------------------------
this.CheckInvalidPathChars = function (path) {
var iipc = new RegExp("[" + this.InternalInvalidPathChars.toString().replace(",", "", "g") + "]");
var isInvalid = path.match(iipc) ? true : false;
return isInvalid;
};
//---------------------------------------------------------
this.FixupPath = function (path) {
//var newPath = "";
//int errorCode = nGetFullPathHelper(path, InternalInvalidPathChars, string.WhitespaceChars, DirectorySeparatorChar, AltDirectorySeparatorChar, VolumeSeparatorChar, false, out newPath);
//if (errorCode != 0)
//{
// __Error.WinIOError(errorCode, path);
//}
//return newPath;
return path;
};
//---------------------------------------------------------
this.IsDirectorySeparator = function (c) {
return c === this.AltDirectorySeparatorChar ||
c === this.DirectorySeparatorChar;
};
//---------------------------------------------------------
this.GetRootLength = function (path) {
if (!this.CheckInvalidPathChars(path)) {
var num = 0;
var length = path.length;
if (length >= 1 && this.IsDirectorySeparator(path.charAt(0))) {
num = 1;
if (length >= 2 && this.IsDirectorySeparator(path.charAt(1))) {
num = 2;
var num3 = 2;
while (num < length && (path.charAt(num) !== this.DirectorySeparatorChar && path.charAt(num) !== this.AltDirectorySeparatorChar || --num3 > 0)) {
num++;
}
}
return num;
}
if (length >= 2 && path.charAt(1) === this.VolumeSeparatorChar) {
num = 2;
if (length >= 3 && this.IsDirectorySeparator(path.charAt(2))) {
num++;
}
}
return num;
}
};
//---------------------------------------------------------
this.GetDirectoryName = function (path) {
/// <summary>
/// Returns the directory information for the specified path string.
/// </summary>
/// <param type="String" type="path">The path of a file or directory.</param>
/// <returns type="String">
/// A System.String containing directory information for path, or null if path
/// denotes a root directory, is the empty string (""), or is null
/// </returns>
if (path !== null) {
var isInvalid = this.CheckInvalidPathChars(path);
path = this.FixupPath(path);
var rootLength = this.GetRootLength(path);
if (path.length > rootLength) {
var length = path.length;
if (length === rootLength) {
return null;
}
while (length > rootLength && path.charAt(--length) !== this.DirectorySeparatorChar && path.charAt(length) !== this.AltDirectorySeparatorChar) {
/* */
}
return path.substr(0, length);
}
}
return null;
};
//---------------------------------------------------------
this.GetExtension = function (path) {
/// <summary>
/// Returns the extension of the specified path string.
/// </summary>
/// <param type="String" type="path">The path of a file or directory.</param>
/// <returns type="String">
/// A System.String containing the extension of the specified path (including
/// the ".")
/// </returns>
if (path !== null) {
if (!this.CheckInvalidPathChars(path)) {
var length = path.length;
var startIndex = length;
while (--startIndex >= 0) {
var ch = path.charAt(startIndex);
if (ch === '.') {
if (startIndex !== length - 1) {
return path.substr(startIndex, length - startIndex);
}
return "";
}
if (ch === this.DirectorySeparatorChar || ch === this.AltDirectorySeparatorChar || ch === this.VolumeSeparatorChar) {
break;
}
}
return "";
}
}
};
//---------------------------------------------------------
this.GetFileName = function (path) {
/// <summary>
/// Returns the file name and extension of the specified path string.
/// </summary>
/// <param type="String" type="path">The path of a file or directory.</param>
/// <returns type="String">
/// A System.String consisting of the characters after the last directory character
/// in path. If the last character of path is a directory or volume separator
/// character, this method returns System.String.Empty. If path is null, this
/// method returns null.
/// </returns>
if (path !== null) {
if (!this.CheckInvalidPathChars(path)) {
var length = path.length;
var num2 = length;
while (--num2 >= 0) {
var ch = path.charAt(num2);
if (ch === this.DirectorySeparatorChar || ch === this.AltDirectorySeparatorChar || ch === this.VolumeSeparatorChar) {
return path.substr(num2 + 1, length - num2 - 1);
}
}
}
}
return path;
};
//---------------------------------------------------------
this.GetFileNameWithoutExtension = function (path) {
/// <summary>
/// Returns the file name of the specified path string without the extension.
/// </summary>
/// <param type="String" type="path">The path of a file or directory.</param>
/// <returns type="String">
/// A System.String containing the string returned by System.IO.Path.GetFileName(System.String),
/// minus the last period (.) and all characters following it.
/// </returns>
path = this.GetFileName(path);
if (path === null) {
return null;
}
var length = path.lastIndexOf('.');
if (length === -1) {
return path;
}
return path.substr(0, length);
};
//---------------------------------------------------------
this.HasExtension = function (path) {
/// <summary>
/// Determines whether a path includes a file name extension.
/// </summary>
/// <param type="String" type="path">The path of a file or directory.</param>
/// <returns type="Bool">
/// true if the characters that follow the last directory separator (\\ or /)
/// or volume separator (:) in the path include a period (.) followed by one
/// or more characters; otherwise, false.
/// </returns>
if (path !== null) {
if (!this.CheckInvalidPathChars(path)) {
var length = path.length;
while (--length >= 0) {
var ch = path.charAt(length);
if (ch === '.') {
return length !== path.length - 1;
}
if (ch === this.DirectorySeparatorChar || ch === this.AltDirectorySeparatorChar || ch === this.VolumeSeparatorChar) {
break;
}
}
}
}
return false;
};
//---------------------------------------------------------
this.GetPathRoot = function (path) {
if (path === null) {
return null;
}
path = this.FixupPath(path);
return path.substr(0, this.GetRootLength(path));
};
//---------------------------------------------------------
this.IsPathRooted = function (path) {
/// <summary>
/// Gets a value indicating whether the specified path string contains absolute
/// or relative path information.
/// </summary>
/// <param type="String" type="path">The path of a file or directory.</param>
/// <returns type="Bool">
/// true if path contains an absolute path; otherwise, false.
/// </returns>
if (path !== null) {
if (!this.CheckInvalidPathChars(path)) {
var length = path.length;
if (length >= 1 && (path.charAt(0) === this.DirectorySeparatorChar || path.charAt(0) === this.AltDirectorySeparatorChar) || length >= 2 && path.charAt(1) === this.VolumeSeparatorChar) {
return true;
}
}
}
return false;
};
//---------------------------------------------------------
this.Combine = function (path1, path2) {
/// <summary>
/// Combines two path strings.
/// </summary>
/// <param type="String" type="path1">The first path.</param>
/// <param type="String" type="path2">The second path.</param>
/// <returns type="Bool">
/// A string containing the combined paths. If one of the specified paths is
/// a zero-length string, this method returns the other path. If path2 contains
/// an absolute path, this method returns path2.
/// </returns>
if (path1 !== null && path2 !== null) {
if (!(this.CheckInvalidPathChars(path1) || this.CheckInvalidPathChars(path2))) {
if (path2.length === 0) {
return path1;
}
if (path1.length === 0) {
return path2;
}
if (this.IsPathRooted(path2)) {
return path2;
}
var ch = path1.charAt(path1.length - 1);
if (ch !== this.DirectorySeparatorChar && ch !== this.AltDirectorySeparatorChar && ch !== this.VolumeSeparatorChar) {
return path1 + this.DirectorySeparatorChar + path2;
}
return path1 + path2;
}
}
};
//---------------------------------------------------------
this.Initialize = function () {
};
this.Initialize.apply(this, arguments);
};
//=============================================================================
// CLASS: System.IO.Stream
//-----------------------------------------------------------------------------
System.IO.Stream = function () {
/// <summary>
/// Initializes a new instance of the <see cref="T:System.IO.Stream" /> class.
/// </summary>
/// <param name="buffer">The array of unsigned bytes from which to create the current stream.</param>
/// <remarks>Created for encryption. System.IO.FileStream can be created with same functions.
/// in order to encrypt/decrypt directry to/from file.
/// </remarks>
//---------------------------------------------------------
// Public Properties
this.Buffer = [];
// The length of the stream in bytes
this.Capacity = 0;
// Number of bytes allocated for this stream.
this.Length = 0;
// Current position within the stream.
this.Position = 0;
// Gets a value indicating whether the current stream supports writing.
this.CanWrite = true;
this.CanRead = true;
//---------------------------------------------------------
// Private Properties.
var isServerSide = false;
var stream = null;
var adTypeBinary = 1, adTypeText = 2, adSaveCreateOverWrite = 2;
//---------------------------------------------------------
this.Read = function (buffer, offset, count) {
/// <summary>
/// Reads a block of bytes from the current stream and writes the data to 'buffer'.
/// <symmary>
/// <param name="buffer">The buffer to read data to.</param>
/// <param name="offset">The byte offset in buffer at which to begin reading.</param>
/// <param name="count">The maximum number of bytes to read.</param>
/// <returns> The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero (0) if the end of the stream has been reached.</returns>
if (offset + count > buffer.length) {
throw new System.Exception("The sum of 'offset' and 'count' is larger than the 'buffer' length.");
}
var num = 0;
if (isServerSide) {
/* */
} else {
num = Math.min(count, this.Buffer.length - this.Position);
for (var i = 0; i < num; i++) {
buffer[offset + i] = this.Buffer[this.Position + i];
}
this.Position += num;
}
return num;
};
//---------------------------------------------------------
this.ToArray = function () {
/// <summary>
/// Writes the stream contents to a byte array, regardless of the System.IO.MemoryStream.Position
/// property.
/// <symmary>
/// <returns>A new byte array.</returns>
var array = [];
if (isServerSide) {
/* */
} else {
array = this.Buffer.slice(0, this.Buffer.length);
}
return array;
};
//---------------------------------------------------------
this.Flush = function () {
/// <summary>
/// Flush stream.
/// <symmary>
if (isServerSide) {
/* */
} else {
/* */
}
};
//---------------------------------------------------------
this.Write = function (buffer, offset, count) {
/// <summary>
/// Writes a block of bytes to the current stream using data read from 'buffer'.
/// <symmary>
/// <param name="buffer">The buffer to write data from.</param>
/// <param name="offset">The byte offset in buffer at which to begin writing from.</param>
/// <param name="count">The maximum number of bytes to write.</param>
if (offset + count > buffer.length) {
throw new System.Exception("The sum of 'offset' and 'count' is greater than the 'buffer' length.");
}
if (isServerSide) {
//stream.Write(contents);
} else {
for (var i = 0; i < count; i++) {
this.Buffer[this.Position + i] = buffer[offset + i];
}
this.Position += count;
}
};
//---------------------------------------------------------
this.WriteTo = function (stream) {
/// <summary>
/// Writes the entire contents of this memory stream to another stream.
/// <summary>
/// <param name="stream">The stream to write this memory stream to.</param>
if (isServerSide) {
/* */
} else {
stream.Write(this.Buffer, 0, this.Buffer.length);
}
};
//---------------------------------------------------------
this.Close = function () {
/// <summary>
/// Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream.
/// </summary>
if (isServerSide) {
stream.Close();
} else {
this.Dispose(true);
}
};
//---------------------------------------------------------
this.CopyTo = function (destination, bufferSize) {
if (arguments.length === 1) bufferSize = 0x1000;
var num = 0;
var buffer = new System.Byte(bufferSize);
while ((num = this.Read(buffer, 0, buffer.length)) !== 0) {
destination.Write(buffer, 0, num);
}
};
//---------------------------------------------------------
this.Dispose = function () {
//delete this.Buffer;
//delete this.Stream;
if (arguments.length === 0) this.Dispose_0();
if (arguments.length === 1) this.Dispose_1(true);
};
this.Dispose_0 = function () {
this.Close();
};
this.Dispose_1 = function (disposing) {
};
//---------------------------------------------------------
this.Initialize = function () {
// isServerSide = (typeof(Response) == "object");
if (isServerSide) {
// Create Stream object
stream = Server.CreateObject("ADODB.Stream");
// Specify stream type - we want To save text/string data.
stream.Type = adTypeBinary;
// Open the stream.
stream.Open();
} else {
if (arguments[0]) {
var buffer = arguments[0];
this.Write(buffer, 0, buffer.length);
this.Capacity = buffer.length;
this.Length = buffer.length;
this.Position = 0;
}
}
};
this.Initialize.apply(this, arguments);
};
System.Type.RegisterClass("System.IO.Stream");
//=============================================================================
// CLASS: System.IO.MemoryStream
//-----------------------------------------------------------------------------
System.IO.MemoryStream = function (buffer) {
/// <summary>
/// Initializes a new instance of the System.IO.MemoryStream class with an expandable
/// capacity initialized to zero.
/// </summary>
var base = System.Type.Inherits(this, new System.IO.Stream());
this.Initialize.apply(this, arguments);
};
System.Type.RegisterClass("System.IO.MemoryStream");
//=============================================================================
// CLASS: System.IO.MemoryStream
//-----------------------------------------------------------------------------
System.IO.InvalidDataException = function (message) {
/// <summary>The exception that is thrown when a data stream is in an invalid format.</summary>
/// <param name="message"" type="String" optional="true" mayBeNull="true">The error message that explains the reason for the exception.</param>
var base = new System.Type.Inherits(this, new System.Exception());
this.message = "";
this.message += message ? message : "Invalid Data.";
var err = Error.create(this.message, { name: this.GetType().FullName });
err.popStackFrame();
return err;
};
System.Type.RegisterClass("System.IO.InvalidDataException");
//==============================================================================
// END
//------------------------------------------------------------------------------