[9f9092]: src / FilePath.cxx  Maximize  Restore  History

Download this file

710 lines (620 with data), 18.1 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
702
703
704
705
706
707
708
709
// SciTE - Scintilla based Text Editor
/** @file FilePath.cxx
** Encapsulate a file path.
**/
// Copyright 1998-2005 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <time.h>
#include <string>
#include <vector>
#include <algorithm>
#if defined(__unix__)
#include <unistd.h>
#if defined(GTK)
#include <gtk/gtk.h>
#endif
#include <dirent.h>
#include <errno.h>
#else
#include <io.h>
#undef _WIN32_WINNT
#define _WIN32_WINNT 0x0500
#ifdef _MSC_VER
// windows.h, et al, use a lot of nameless struct/unions - can't fix it, so allow it
#pragma warning(disable: 4201)
#endif
#include <windows.h>
#ifdef _MSC_VER
// okay, that's done, don't allow it in our code
#pragma warning(default: 4201)
// Turn off MS dislike of POSIX
#pragma warning(disable: 4996)
#endif
#include <commctrl.h>
// For chdir
#ifdef _MSC_VER
#include <direct.h>
#endif
#ifdef __DMC__
#include <dir.h>
#endif
#ifdef __MINGW32_VERSION
#include <direct.h>
#endif
#endif
#include "Scintilla.h"
#include "GUI.h"
#include "SString.h"
#include "FilePath.h"
#if defined(__unix__)
const GUI::gui_char pathSepString[] = "/";
const GUI::gui_char pathSepChar = '/';
const GUI::gui_char listSepString[] = ":";
const GUI::gui_char configFileVisibilityString[] = ".";
const GUI::gui_char fileRead[] = "rb";
const GUI::gui_char fileWrite[] = "wb";
#endif
#ifdef WIN32
// Windows
const GUI::gui_char pathSepString[] = GUI_TEXT("\\");
const GUI::gui_char pathSepChar = '\\';
const GUI::gui_char listSepString[] = GUI_TEXT(";");
const GUI::gui_char configFileVisibilityString[] = GUI_TEXT("");
const GUI::gui_char fileRead[] = GUI_TEXT("rb");
const GUI::gui_char fileWrite[] = GUI_TEXT("wb");
#endif
FilePath::FilePath(const GUI::gui_char *fileName_) : fileName(fileName_ ? fileName_ : GUI_TEXT("")) {}
FilePath::FilePath(const GUI::gui_string &fileName_) : fileName(fileName_) {}
FilePath::FilePath(FilePath const &directory, FilePath const &name) {
Set(directory, name);
}
void FilePath::Set(const GUI::gui_char *fileName_) {
fileName = fileName_;
}
void FilePath::Set(FilePath const &other) {
fileName = other.fileName;
}
void FilePath::Set(FilePath const &directory, FilePath const &name) {
if (name.IsAbsolute()) {
fileName = name.fileName;
} else {
fileName = directory.fileName;
if (fileName.size() && (fileName[fileName.size()-1] != pathSepChar))
fileName += pathSepString;
fileName += name.fileName;
}
}
void FilePath::SetDirectory(FilePath directory) {
FilePath curName(*this);
Set(directory, curName);
}
void FilePath::Init() {
fileName = GUI_TEXT("");
}
bool FilePath::operator==(const FilePath &other) const {
return SameNameAs(other);
}
bool FilePath::operator<(const FilePath &other) const {
return fileName < other.fileName;
}
bool FilePath::SameNameAs(const GUI::gui_char *other) const {
#ifdef WIN32
return CSTR_EQUAL == CompareString(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE,
fileName.c_str(), -1, other, -1);
#else
return fileName == other;
#endif
}
bool FilePath::SameNameAs(const FilePath &other) const {
return SameNameAs(other.fileName.c_str());
}
bool FilePath::IsSet() const {
return fileName.length() > 0;
}
bool FilePath::IsUntitled() const {
size_t dirEnd = fileName.rfind(pathSepChar);
return (dirEnd == GUI::gui_string::npos) || (!fileName[dirEnd+1]);
}
bool FilePath::IsAbsolute() const {
if (fileName.length() == 0)
return false;
#ifdef __unix__
if (fileName[0] == '/')
return true;
#endif
#ifdef WIN32
if (fileName[0] == pathSepChar || fileName[1] == ':') // UNC path or drive separator
return true;
#endif
return false;
}
bool FilePath::IsRoot() const {
#ifdef WIN32
if ((fileName[0] == pathSepChar) && (fileName[1] == pathSepChar) && (fileName.find(pathSepString, 2) == GUI::gui_string::npos))
return true; // UNC path like \\server
return (fileName.length() == 3) && (fileName[1] == ':') && (fileName[2] == pathSepChar);
#else
return fileName == "/";
#endif
}
int FilePath::RootLength() {
#ifdef WIN32
return 3;
#else
return 1;
#endif
}
const GUI::gui_char *FilePath::AsInternal() const {
return fileName.c_str();
}
std::string FilePath::AsUTF8() const {
return GUI::UTF8FromString(fileName);
}
FilePath FilePath::Name() const {
size_t dirEnd = fileName.rfind(pathSepChar);
if (dirEnd != GUI::gui_string::npos)
return fileName.substr(dirEnd + 1);
else
return fileName;
}
FilePath FilePath::BaseName() const {
size_t dirEnd = fileName.rfind(pathSepChar);
size_t extStart = fileName.rfind('.');
if (dirEnd != GUI::gui_string::npos) {
if (extStart > dirEnd) {
return FilePath(fileName.substr(dirEnd + 1, extStart - dirEnd - 1));
} else {
return FilePath(fileName.substr(dirEnd + 1));
}
} else if (extStart) {
return FilePath(fileName.substr(0, extStart));
} else {
return fileName;
}
}
FilePath FilePath::Extension() const {
size_t dirEnd = fileName.rfind(pathSepChar);
size_t extStart = fileName.rfind('.');
if ((extStart != GUI::gui_string::npos) && (extStart > dirEnd))
return fileName.substr(extStart + 1);
else
return GUI_TEXT("");
}
FilePath FilePath::Directory() const {
if (IsRoot()) {
return FilePath(fileName.c_str());
} else {
size_t lenDirectory = fileName.rfind(pathSepChar);
if (lenDirectory != GUI::gui_string::npos) {
if (lenDirectory < static_cast<size_t>(RootLength())) {
lenDirectory = static_cast<size_t>(RootLength());
}
return FilePath(fileName.substr(0, lenDirectory));
} else {
return FilePath();
}
}
}
#ifdef _WIN32
// Substitute functions that take wchar_t arguments but have the same name
// as char functions so that the compiler will choose the right form.
static size_t strlen(const wchar_t *str) {
return wcslen(str);
}
static wchar_t *strcpy(wchar_t *strDestination, const wchar_t *strSource) {
return wcscpy(strDestination, strSource);
}
static int strcmp(const wchar_t *a, const wchar_t *b) {
return wcscmp(a,b);
}
static wchar_t *strchr(wchar_t *str, wchar_t c) {
return wcschr(str, c);
}
static wchar_t *strrchr(wchar_t *str, wchar_t c) {
return wcsrchr(str, c);
}
static wchar_t *getcwd(wchar_t *buffer, int maxlen) {
return _wgetcwd(buffer, maxlen);
}
static int chdir(const wchar_t *dirname) {
return _wchdir(dirname);
}
static FILE *fopen(const wchar_t *filename, const wchar_t *mode) {
return _wfopen(filename, mode);
}
static int unlink(const wchar_t *filename) {
return _wunlink(filename);
}
static int access(const wchar_t *path, int mode) {
return _waccess(path, mode);
}
#if defined(_MSC_VER) && (_MSC_VER > 1310)
static int stat(const wchar_t *path, struct _stat64i32 *buffer) {
return _wstat(path, buffer);
}
#else
static int stat(const wchar_t *path, struct _stat *buffer) {
return _wstat(path, buffer);
}
#endif
#endif
static GUI::gui_char *split(GUI::gui_char*& s, GUI::gui_char c) {
GUI::gui_char *t = s;
if (s && (s = strchr(s, c)) != NULL)
* s++ = '\0';
return t;
}
FilePath FilePath::NormalizePath() const {
GUI::gui_char *path = new GUI::gui_char[fileName.length() + 1];
strcpy(path, AsInternal());
#ifdef WIN32
// Convert unix path separators to Windows
for (GUI::gui_char *cp = path; *cp; cp++) {
if (*cp == '/')
*cp = pathSepChar;
}
#endif
GUI::gui_char *absPath = new GUI::gui_char[fileName.length() + 1];
GUI::gui_char *cur = absPath;
*cur = '\0';
GUI::gui_char *tmp = path;
if (*tmp == pathSepChar) {
*cur++ = pathSepChar;
*cur = '\0';
tmp++;
}
GUI::gui_char *part;
while ((part = split(tmp, pathSepChar)) != NULL) {
GUI::gui_char *last;
if (strcmp(part, GUI_TEXT(".")) == 0)
;
else if (strcmp(part, GUI_TEXT("..")) == 0 && (last = strrchr(absPath, pathSepChar)) != NULL) {
if (last > absPath)
cur = last;
else
cur = last + 1;
*cur = '\0';
} else {
if (cur > absPath && *(cur - 1) != pathSepChar)
*cur++ = pathSepChar;
strcpy(cur, part);
cur += strlen(part);
}
}
FilePath ret(absPath);
delete []path;
delete []absPath;
return ret;
}
/**
* Take a filename or relative path and put it at the end of the current path.
* If the path is absolute, return the same path.
*/
FilePath FilePath::AbsolutePath() const {
#ifdef WIN32
// The runtime libraries for GCC and Visual C++ give different results for _fullpath
// so use the OS.
GUI::gui_char absPath[2000];
absPath[0] = '\0';
GUI::gui_char *fileBit = 0;
::GetFullPathNameW(AsInternal(), sizeof(absPath)/sizeof(absPath[0]), absPath, &fileBit);
return FilePath(absPath);
#else
if (IsAbsolute()) {
return NormalizePath();
} else {
return FilePath(GetWorkingDirectory(), *this).NormalizePath();
}
#endif
}
// Only used on Windows to fix the case of file names
FilePath FilePath::GetWorkingDirectory() {
GUI::gui_char dir[MAX_PATH + 1];
dir[0] = '\0';
if (getcwd(dir, MAX_PATH)) {
dir[MAX_PATH] = '\0';
// In Windows, getcwd returns a trailing backslash
// when the CWD is at the root of a disk, so remove it
size_t endOfPath = strlen(dir) - 1;
if (dir[endOfPath] == pathSepChar) {
dir[endOfPath] = '\0';
}
}
return FilePath(dir);
}
bool FilePath::SetWorkingDirectory() const {
return chdir(AsInternal()) == 0;
}
void FilePath::List(FilePathSet &directories, FilePathSet &files) {
#ifdef WIN32
FilePath wildCard(*this, GUI_TEXT("*.*"));
bool complete = false;
WIN32_FIND_DATAW findFileData;
HANDLE hFind = ::FindFirstFileW(wildCard.AsInternal(), &findFileData);
if (hFind != INVALID_HANDLE_VALUE) {
while (!complete) {
if ((strcmp(findFileData.cFileName, GUI_TEXT(".")) != 0) && (strcmp(findFileData.cFileName, GUI_TEXT("..")) != 0)) {
if (findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
directories.push_back(FilePath(AsInternal(), findFileData.cFileName));
} else {
files.push_back(FilePath(AsInternal(), findFileData.cFileName));
}
}
if (!::FindNextFileW(hFind, &findFileData)) {
complete = true;
}
}
::FindClose(hFind);
}
#else
errno = 0;
DIR *dp = opendir(AsInternal());
if (dp == NULL) {
//~ fprintf(stderr, "%s: cannot open for reading: %s\n", AsInternal(), strerror(errno));
return;
}
struct dirent *ent;
while ((ent = readdir(dp)) != NULL) {
if ((strcmp(ent->d_name, ".") != 0) && (strcmp(ent->d_name, "..") != 0)) {
FilePath pathFull(AsInternal(), ent->d_name);
if (pathFull.IsDirectory()) {
directories.push_back(pathFull);
} else {
files.push_back(pathFull);
}
}
}
closedir(dp);
#endif
std::sort(files.begin(), files.end());
std::sort(directories.begin(), directories.end());
}
FILE *FilePath::Open(const GUI::gui_char *mode) const {
if (IsSet()) {
return fopen(fileName.c_str(), mode);
} else {
return NULL;
}
}
void FilePath::Remove() const {
unlink(AsInternal());
}
#ifndef R_OK
// Microsoft does not define the constants used to call access
#define R_OK 4
#endif
time_t FilePath::ModifiedTime() const {
if (IsUntitled())
return 0;
if (access(AsInternal(), R_OK) == -1)
return 0;
#ifdef _WIN32
#if defined(_MSC_VER) && (_MSC_VER > 1310)
struct _stat64i32 statusFile;
#else
struct _stat statusFile;
#endif
#else
struct stat statusFile;
#endif
if (stat(AsInternal(), &statusFile) != -1)
return statusFile.st_mtime;
else
return 0;
}
long FilePath::GetFileLength() const {
long size = -1;
if (IsSet()) {
FILE *fp = Open(fileRead);
if (fp) {
fseek(fp, 0, SEEK_END);
size = ftell(fp);
fseek(fp, 0, SEEK_SET);
fclose(fp);
}
}
return size;
}
bool FilePath::Exists() const {
bool ret = false;
if (IsSet()) {
FILE *fp = Open(fileRead);
if (fp) {
ret = true;
fclose(fp);
}
}
return ret;
}
bool FilePath::IsDirectory() const {
#ifdef _WIN32
#if defined(_MSC_VER) && (_MSC_VER > 1310)
struct _stat64i32 statusFile;
#else
struct _stat statusFile;
#endif
#else
struct stat statusFile;
#endif
if (stat(AsInternal(), &statusFile) != -1)
#ifdef WIN32
return statusFile.st_mode & _S_IFDIR;
#else
return statusFile.st_mode & S_IFDIR;
#endif
else
return false;
}
#ifdef _WIN32
void Lowercase(GUI::gui_string &s) {
int chars = ::LCMapString(LOCALE_SYSTEM_DEFAULT, LCMAP_LOWERCASE, s.c_str(), s.size()+1, NULL, 0);
std::vector<wchar_t> vc(chars);
::LCMapString(LOCALE_SYSTEM_DEFAULT, LCMAP_LOWERCASE, s.c_str(), s.size()+1, &vc[0], chars);
s = &vc[0];
}
#endif
static bool EndMatches(GUI::gui_string const &s, GUI::gui_string const &end) {
return (s.size() >= end.size()) &&
(std::equal(s.begin() + s.size() - end.size(), s.end(), end.begin()));
}
bool FilePath::Matches(const GUI::gui_char *pattern) const {
GUI::gui_string pat(pattern);
GUI::gui_string nameCopy(Name().fileName);
#ifdef _WIN32
Lowercase(pat);
Lowercase(nameCopy);
#endif
std::replace(pat.begin(), pat.end(), ' ', '\0');
size_t start = 0;
while (start < pat.length()) {
const GUI::gui_char *patElement = pat.c_str() + start;
if (patElement[0] == '*') {
if (EndMatches(nameCopy, patElement + 1)) {
return true;
}
} else {
if (nameCopy == patElement) {
return true;
}
}
start += strlen(patElement) + 1;
}
return false;
}
#ifdef WIN32
/**
* Makes a long path from a given, possibly short path/file.
*
* The short path/file must exist, and if it is a file it must be fully specified
* otherwise the function fails.
*
* sizeof @a longPath buffer must be a least _MAX_PATH
* @returns true on success, and the long path in @a longPath buffer,
* false on failure, and copies the @a shortPath arg to the @a longPath buffer.
*/
static bool MakeLongPath(const GUI::gui_char* shortPath, GUI::gui_char* longPath) {
bool ok = ::GetLongPathNameW(shortPath, longPath, _MAX_PATH) != 0;
if (!ok) {
wcsncpy(longPath, shortPath, _MAX_PATH);
}
return ok;
}
#endif
void FilePath::FixName() {
#ifdef WIN32
// Only used on Windows to use long file names and fix the case of file names
GUI::gui_char longPath[_MAX_PATH];
// first try MakeLongPath which corrects the path and the case of filename too
if (MakeLongPath(AsInternal(), longPath)) {
Set(longPath);
} else {
// On Windows file comparison is done case insensitively so the user can
// enter scite.cxx and still open this file, SciTE.cxx. To ensure that the file
// is saved with correct capitalisation FindFirstFile is used to find out the
// real name of the file.
WIN32_FIND_DATAW FindFileData;
HANDLE hFind = ::FindFirstFileW(AsInternal(), &FindFileData);
FilePath dir = Directory();
if (hFind != INVALID_HANDLE_VALUE) { // FindFirstFile found the file
Set(dir, FindFileData.cFileName);
::FindClose(hFind);
}
}
#endif
}
std::string CommandExecute(const GUI::gui_char *command, const GUI::gui_char *directoryForRun) {
std::string output;
char buffer[16 * 1024];
#ifdef _WIN32
SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), 0, 0};
sa.bInheritHandle = TRUE;
sa.lpSecurityDescriptor = NULL;
SECURITY_DESCRIPTOR sd;
// Make a real security thing to allow inheriting handles
::InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION);
::SetSecurityDescriptorDacl(&sd, TRUE, NULL, FALSE);
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.lpSecurityDescriptor = &sd;
HANDLE hPipeWrite = NULL;
HANDLE hPipeRead = NULL;
// Create pipe for output redirection
// read handle, write handle, security attributes, number of bytes reserved for pipe - 0 default
::CreatePipe(&hPipeRead, &hPipeWrite, &sa, 0);
// Create pipe for input redirection. In this code, you do not
// redirect the output of the child process, but you need a handle
// to set the hStdInput field in the STARTUP_INFO struct. For safety,
// you should not set the handles to an invalid handle.
HANDLE hWriteSubProcess = NULL;
//subProcessGroupId = 0;
HANDLE hRead2 = NULL;
// read handle, write handle, security attributes, number of bytes reserved for pipe - 0 default
::CreatePipe(&hRead2, &hWriteSubProcess, &sa, 0);
::SetHandleInformation(hPipeRead, HANDLE_FLAG_INHERIT, 0);
::SetHandleInformation(hWriteSubProcess, HANDLE_FLAG_INHERIT, 0);
// Make child process use hPipeWrite as standard out, and make
// sure it does not show on screen.
STARTUPINFOW si = {
sizeof(STARTUPINFO), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
si.wShowWindow = SW_HIDE;
si.hStdInput = hRead2;
si.hStdOutput = hPipeWrite;
si.hStdError = hPipeWrite;
PROCESS_INFORMATION pi = {0, 0, 0, 0};
bool running = ::CreateProcessW(
NULL,
const_cast<wchar_t *>(command),
NULL, NULL,
TRUE, CREATE_NEW_PROCESS_GROUP,
NULL,
(directoryForRun && directoryForRun[0]) ? directoryForRun : 0,
&si, &pi);
if (running) {
// Wait until child process exits but time out after 5 seconds.
::WaitForSingleObject(pi.hProcess, 5 * 1000);
DWORD bytesRead = 0;
DWORD bytesAvail = 0;
if (::PeekNamedPipe(hPipeRead, buffer, sizeof(buffer), &bytesRead, &bytesAvail, NULL)) {
if (bytesAvail > 0) {
int bTest = ::ReadFile(hPipeRead, buffer, sizeof(buffer), &bytesRead, NULL);
while (bTest && bytesRead) {
output.append(buffer, buffer+bytesRead);
bytesRead = 0;
if (::PeekNamedPipe(hPipeRead, buffer, sizeof(buffer), &bytesRead, &bytesAvail, NULL)) {
if (bytesAvail) {
bTest = ::ReadFile(hPipeRead, buffer, sizeof(buffer), &bytesRead, NULL);
}
}
}
}
}
}
::CloseHandle(pi.hProcess);
::CloseHandle(pi.hThread);
::CloseHandle(hPipeRead);
::CloseHandle(hPipeWrite);
::CloseHandle(hRead2);
::CloseHandle(hWriteSubProcess);
#else
FilePath startDirectory= FilePath::GetWorkingDirectory(); // Save
FilePath(directoryForRun).SetWorkingDirectory();
FILE *fp = popen(command, "r");
if (fp) {
size_t lenData = fread(buffer, 1, sizeof(buffer), fp);
while (lenData > 0) {
output.append(buffer, buffer+lenData);
lenData = fread(buffer, 1, sizeof(buffer), fp);
}
pclose(fp);
}
startDirectory.SetWorkingDirectory();
#endif
return output;
}

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks