001:
002:
003:
004:
005:
006:
007:
008:
009:
010:
011:
012:
013:
014:
015:
016:
017:
018:
019:
020:
021:
022:
023:
024:
025:
026:
027:
028:
029:
030:
031:
032:
033:
034:
035:
036:
037:
038:
039:
040:
041:
042:
043:
044:
045:
046:
047:
048:
049:
050:
051:
052:
053:
054:
055:
056:
057:
058:
059:
060:
061:
062:
063:
064:
065:
066:
067:
068:
069:
070:
071:
072:
073:
074:
075:
076:
077:
078:
079:
080:
081:
082:
083:
084:
085:
086:
087:
088:
089:
090:
091:
092:
093:
094:
095:
096:
097:
098:
099:
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:
710:
711:
712:
713:
714:
715:
716:
717:
718:
719:
720:
721:
722:
723:
724:
725:
726:
727:
728:
729:
730:
731:
732:
733:
734:
735:
736:
737:
738:
739:
740:
741:
742:
743:
744:
745:
746:
747:
748:
749:
750:
751:
752:
753:
754:
755:
756:
757:
758:
759:
760:
761:
762:
763:
764:
765:
766:
767:
768:
769:
770:
771:
772:
773:
774:
775:
776:
777:
778:
779:
780:
781:
782:
783:
784:
785:
786:
787:
788:
789:
790:
791:
792:
793:
794:
795:
796:
797:
798:
799:
800:
801:
802:
803:
804:
805:
806:
807:
808:
809:
810:
811:
812:
813:
814:
815:
816:
817:
818:
819:
820:
821:
822:
823:
824:
825:
826:
827:
828:
829:
830:
831:
832:
833:
834:
835:
836:
837:
838:
839:
840:
841:
842:
843:
844:
845:
846:
847:
848:
849:
850:
851:
852:
853:
854:
855:
856:
857:
858:
859:
860:
861:
862:
863:
864:
865:
866:
867:
868:
869:
870:
871:
872:
873:
874:
875:
876:
877:
878:
879:
880:
881:
882:
883:
884:
885:
886:
887:
888:
889:
890:
891:
892:
893:
894:
895:
896:
897:
898:
899:
900:
901:
902:
903:
904:
905:
906:
907:
908:
909:
910:
911:
912:
913:
914:
915:
916:
917:
918:
919:
920:
921:
922:
923:
924:
925:
926:
927:
928:
929:
930:
931:
932:
933:
934:
935:
936:
937:
938:
939:
940:
941:
942:
943:
944:
945:
946:
947:
948:
949:
950:
951:
952:
953:
954:
955:
956:
957:




/*
* Copyright (c), Zeriph Enterprises
* All rights reserved.
*
* Contributor(s):
* Zechariah Perez, omni (at) zeriph (dot) com
*
* THIS SOFTWARE IS PROVIDED BY ZERIPH AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL ZERIPH AND CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* DEV_NOTE: this file is not intended to be used directly by any user code!
i.e. do not #include <omni/xxx_impl.hxx> and do not compile this source directly.
this file is included directly in other source.
*/
// so as not to accidentally build this file with the source this macro is defined in io.cpp
#if !defined(OMNI_IO_FILE_FW) || !defined(OMNI_PATH_FW) || !defined(OMNI_L_FW) || !defined(OMNI_STRING_T_FW)
#error "invalid preprocessor directive detected"
#endif
#if defined(OMNI_IO_FILE_INTERNAL_FW)
namespace omni {
namespace io {
namespace file_internal {
#if defined(OMNI_OS_WIN)
/* DEV_NOTE: this code is Windows only .. it returns the short/long path name for a file
but that is largely irrelevant as it only returns an 8.3 short path name if it is enabled
in the registry for above Windows XP. Since this is a one-off type of thing and likely
not largely used, this will not be exposed or documented beyond this file scope. */
std::string get_path_name(const std::string& file)
{
std::string name = "\\\\?\\";
long length = ::GetShortPathNameA(file.c_str(), NULL, 0);
if (length > 0) {
char* buffer = new char[length];
length = ::GetShortPathNameA(file.c_str(), buffer, length);
if (length > 0) {
std::string npath(buffer);
delete[] buffer;
name += npath;
} else {
delete[] buffer;
}
} else {
name += file;
}
return name;
}
std::wstring get_path_name(const std::wstring& file)
{
std::wstring name = L"\\\\?\\";
long length = ::GetShortPathNameW(file.c_str(), NULL, 0);
if (length > 0) {
wchar_t* buffer = new wchar_t[length];
length = ::GetShortPathNameW(file.c_str(), buffer, length);
if (length > 0) {
std::wstring npath(buffer);
delete[] buffer;
name += npath;
} else {
delete[] buffer;
}
} else {
name += file;
}
return name;
}
bool win_copy_file(const std::string& file, const std::string& new_name)
{
OMNI_FILE_CHECKA_FW(file, false)
OMNI_FILE_CHECKA_FW(new_name, false)
BOOL res = ::CopyFileA(file.c_str(), new_name.c_str(), FALSE); // don't fail if exists (e.g. overwrite)
if (res == 0) {
if (OMNI_GLE == ERROR_FILE_NOT_FOUND) {
OMNI_ERRV_RETV_FW(OMNI_FILE_NOT_FOUND_STR, omni::string::to_string_t(file), omni::exceptions::file_not_found(omni::string::to_string(file)), false);
} else {
std::string ex = OMNI_PATH_NOT_ACCESSIBLE_STR;
ex += omni::string::util::to_string(OMNI_GLE);
OMNI_ERRV_RETV_FW(OMNI_PATH_NOT_ACCESSIBLE_STR, omni::string::to_string_t(file), omni::exceptions::path_exception(ex, file), false)
}
}
return true;
}
bool win_copy_file(const std::wstring& file, const std::wstring& new_name)
{
std::wstring tf = OMNI_FILE_CHECKW_FW(tf, file, false)
std::wstring nf = OMNI_FILE_CHECKW_FW(nf, new_name, false)
BOOL res = ::CopyFileW(tf.c_str(), nf.c_str(), FALSE); // don't fail if exists (e.g. overwrite)
if (res == 0) {
if (OMNI_GLE == ERROR_FILE_NOT_FOUND) {
OMNI_ERRV_RETV_FW(OMNI_FILE_NOT_FOUND_STR, omni::string::to_string_t(file), omni::exceptions::file_not_found(omni::string::to_string(file)), false);
} else {
std::string ex = OMNI_PATH_NOT_ACCESSIBLE_STR;
ex += omni::string::util::to_string(OMNI_GLE);
OMNI_ERRV_RETV_FW(OMNI_PATH_NOT_ACCESSIBLE_STR, omni::string::to_string_t(file), omni::exceptions::path_exception(ex, omni::string::to_string(file)), false)
}
}
return true;
}
#endif
template < typename STR, typename ISTREAM, typename OSTREAM >
bool copy(const STR& file, const STR& new_name)
{
#if defined(OMNI_IO_FILE_COPY_USE_FSTREAM)
ISTREAM src(omni::string::to_string(file).c_str(), std::ios::binary);
if (!src.is_open()) {
src.close();
OMNI_ERRV_RETV_FW(OMNI_PATH_NOT_ACCESSIBLE_STR, omni::string::to_string_t(file), omni::exceptions::path_exception(OMNI_PATH_NOT_ACCESSIBLE_STR,omni::string::to_string(file)), false)
}
OSTREAM dst(omni::string::to_string(new_name).c_str(), std::ios::binary);
if (!dst.is_open()) {
src.close();
dst.close();
OMNI_ERRV_RETV_FW(OMNI_PATH_NOT_ACCESSIBLE_STR, omni::string::to_string_t(new_name), omni::exceptions::path_exception(OMNI_PATH_NOT_ACCESSIBLE_STR, omni::string::to_string(new_name)), false)
}
dst << src.rdbuf();
src.close();
dst.close();
return true;
#else
#if defined(OMNI_OS_WIN)
return win_copy_file(file, new_name);
#else
char buf[OMNI_IO_FILE_COPY_BUFSZ] = {0};
int64_t size = 0;
int src = ::open(omni::string::to_string(file).c_str(), O_RDONLY, 0);
if (src == -1) {
::close(src);
OMNI_ERRV_RETV_FW(OMNI_PATH_NOT_ACCESSIBLE_STR, omni::string::to_string_t(file), omni::exceptions::path_exception(OMNI_PATH_NOT_ACCESSIBLE_STR,omni::string::to_string(file)), false)
}
// TODO: pass in user perms here
int dst = ::open(omni::string::to_string(new_name).c_str(), O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR); // | O_TRUNC);
if (dst == -1) {
::close(src);
::close(dst);
OMNI_ERRV_RETV_FW(OMNI_PATH_NOT_ACCESSIBLE_STR, omni::string::to_string_t(new_name), omni::exceptions::path_exception(OMNI_PATH_NOT_ACCESSIBLE_STR, omni::string::to_string(new_name)), false)
}
while ((size = ::read(src, buf, OMNI_IO_FILE_COPY_BUFSZ)) > 0) {
if (::write(dst, buf, static_cast<size_t>(size)) == -1) {
// TODO: debug print
break;
} else {
std::memset(buf, 0, OMNI_IO_FILE_COPY_BUFSZ);
}
}
::close(src);
::close(dst);
return true;
#endif
#endif
}
bool copy(const std::string& file, const std::string& new_name)
{
#if defined(OMNI_OS_WIN) && defined(OMNI_WIN_API)
OMNI_FILE_CHECKA_FW(file, false)
if (::CopyFileA(file.c_str(), new_name.c_str(), FALSE) == 0) {
OMNI_DBGEV("error copying file: ", omni::string::to_string_t(omni::system::last_error_str()));
return false;
}
return omni::io::file_internal::exists(new_name);
#else
return omni::io::file_internal::copy<std::string, std::ifstream, std::ofstream>(file, new_name);
#endif
}
bool copy(const std::wstring& file, const std::wstring& new_name)
{
#if defined(OMNI_OS_WIN) && defined(OMNI_WIN_API)
std::wstring tf = OMNI_FILE_CHECKW_FW(tf, file, false)
std::wstring nf = OMNI_FILE_CHECKW_FW(nf, new_name, false)
if (::CopyFileW(tf.c_str(), nf.c_str(), FALSE) == 0) {
OMNI_DBGEV("error copying file: ", omni::string::to_string_t(omni::system::last_error_str()));
return false;
}
return omni::io::file_internal::exists(new_name);
#else
return omni::io::file_internal::copy<std::wstring, std::wifstream, std::wofstream>(file, new_name);
#endif
}
template < typename STR, typename OSTREAM >
bool create(const STR& file, const omni::io::options& io_ops)
{
bool create_path = ((io_ops & omni::io::options::CREATE_PATH) == omni::io::options::CREATE_PATH);
STR parent = omni::io::path::get_parent_name(file);
if (create_path && !omni::io::directory::exists(parent)) {
if (!omni::io::directory::create(parent)) {
return false;
}
}
OSTREAM out(omni::string::to_string(file).c_str(), std::ios::binary|std::ios::out);
out.close(); // close/flush
return omni::io::file_internal::exists(file);
}
bool create(const std::string& file, const omni::io::options& io_ops)
{
bool create_path = ((io_ops & omni::io::options::CREATE_PATH) == omni::io::options::CREATE_PATH);
#if defined(OMNI_OS_WIN) && defined(OMNI_WIN_API)
if (create_path) {
std::string parent = omni::io::path::get_parent_name(file);
if (create_path && !omni::io::directory::exists(parent)) {
if (!omni::io::directory::create(parent)) {
return false;
}
}
}
OMNI_FILE_CHECKA_FW(file, false)
HANDLE hfile = ::CreateFileA(file.c_str(), GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
if (hfile == INVALID_HANDLE_VALUE) {
OMNI_DBGEV("error creating file: ", omni::system::last_error_str().c_str())
return false;
}
::CloseHandle(hfile);
return omni::io::file_internal::exists(file);
#else
return omni::io::file_internal::create<std::string, std::ofstream>(file, create_path);
#endif
}
bool create(const std::wstring& file, const omni::io::options& io_ops)
{
bool create_path = ((io_ops & omni::io::options::CREATE_PATH) == omni::io::options::CREATE_PATH);
#if defined(OMNI_OS_WIN) && defined(OMNI_WIN_API)
if (create_path) {
std::wstring parent = omni::io::path::get_parent_name(file);
if (create_path && !omni::io::directory::exists(parent)) {
if (!omni::io::directory::create(parent)) {
return false;
}
}
}
std::wstring tf = OMNI_FILE_CHECKW_FW(tf, file, false)
HANDLE hfile = ::CreateFileW(tf.c_str(), GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
if (hfile == INVALID_HANDLE_VALUE) {
OMNI_DBGEV("error creating file: ", omni::system::last_error_str().c_str())
return false;
}
::CloseHandle(hfile);
return omni::io::file_internal::exists(file);
#else
return omni::io::file_internal::create<std::wstring, std::wofstream>(file, create_path);
#endif
}
template < typename STR, typename ISTRM, typename SSTRM >
STR get_contents(const STR& file)
{
ISTRM ifile(omni::string::to_string(file).c_str());
SSTRM buf;
buf << ifile.rdbuf();
return buf.str();
}
std::string get_contents(const std::string& file)
{
return get_contents<std::string, std::ifstream, std::stringstream>(file);
}
std::wstring get_contents(const std::wstring& file)
{
return get_contents<std::wstring, std::wifstream, std::wstringstream>(file);
}
uint64_t get_size(const std::string& file)
{
#if defined(OMNI_OS_WIN)
#if defined(OMNI_WIN_API)
OMNI_FILE_CHECKA_FW(file, 0)
WIN32_FILE_ATTRIBUTE_DATA finfo;
if (::GetFileAttributesExA(file.c_str(), GetFileExInfoStandard, &finfo) == 0) {
return 0;
}
LARGE_INTEGER sz;
sz.HighPart = finfo.nFileSizeHigh;
sz.LowPart = finfo.nFileSizeLow;
return static_cast<uint64_t>(sz.QuadPart);
#else
struct stat fi;
if (::_stat(file.c_str(), &fi) == 0) {
return static_cast<uint64_t>(fi.st_size);
}
return 0;
#endif
#else
struct stat fi;
if (::stat(file.c_str(), &fi) == 0) {
return static_cast<uint64_t>(fi.st_size);
}
return 0;
#endif
}
uint64_t get_size(const std::wstring& file)
{
#if defined(OMNI_OS_WIN)
#if defined(OMNI_WIN_API)
std::wstring tf = OMNI_FILE_CHECKW_FW(tf, file, 0)
WIN32_FILE_ATTRIBUTE_DATA finfo;
if (::GetFileAttributesExW(tf.c_str(), GetFileExInfoStandard, &finfo) == 0) {
return 0;
}
LARGE_INTEGER sz;
sz.HighPart = finfo.nFileSizeHigh;
sz.LowPart = finfo.nFileSizeLow;
return static_cast<uint64_t>(sz.QuadPart);
#else
struct stat fi;
if (::_wstat(file.c_str(), &fi) == 0) {
return static_cast<uint64_t>(fi.st_size);
}
return 0;
#endif
#else
struct stat fi;
if (::stat(omni::string::to_string(file).c_str(), &fi) == 0) {
return static_cast<uint64_t>(fi.st_size);
}
return 0;
#endif
}
bool mv(const std::string& file, const std::string& new_name, const omni::io::options& io_ops)
{
bool overwrite = ((io_ops & omni::io::options::OVERWRITE) == omni::io::options::OVERWRITE);
bool create_path = ((io_ops & omni::io::options::CREATE_PATH) == omni::io::options::CREATE_PATH);
if (!omni::io::cfile::exists(file)) {
OMNI_DV1_FW("file does not exists:", file);
return false;
}
if (!overwrite && omni::io::file_internal::exists(new_name)) {
OMNI_DBGEV("New path already exists: ", omni::string::to_string_t(new_name));
return false;
}
std::string root = omni::io::cpath::get_parent_name(new_name);
if (!omni::io::cdirectory::exists(root)) {
if (create_path) {
if (!omni::io::cdirectory::create(root, true)) {
OMNI_D1_FW("could not create parent directory");
return false;
}
} else {
OMNI_D1_FW("error moving file: new path does not exist");
return false;
}
}
#if defined(OMNI_OS_WIN)
#if defined(OMNI_WIN_API)
OMNI_FILE_CHECKA_FW(file, false)
OMNI_FILE_CHECKA_FW(new_name, false)
BOOL ret = ::MoveFileA(file.c_str(), new_name.c_str());
if (ret == 0) {
OMNI_DV1_FW("error moving file: ", omni::system::last_error_str().c_str());
return false;
}
#else
int ret = ::_rename(file.c_str(), new_name.c_str());
if (ret != 0) {
OMNI_DV1_FW("error moving file: ", omni::string::to_string_t(omni::system::error_str(ret)));
return false;
}
#endif
#else
int ret = ::rename(file.c_str(), new_name.c_str());
if (ret != 0) {
OMNI_DV1_FW("error moving file: ", omni::string::to_string_t(omni::system::error_str(ret)));
return false;
}
#endif
return omni::io::file_internal::exists(new_name);
}
bool mv(const std::wstring& file, const std::wstring& new_name, const omni::io::options& io_ops)
{
bool overwrite = ((io_ops & omni::io::options::OVERWRITE) == omni::io::options::OVERWRITE);
bool create_path = ((io_ops & omni::io::options::CREATE_PATH) == omni::io::options::CREATE_PATH);
if (!omni::io::wfile::exists(file)) {
OMNI_DV1_FW("file does not exists:", omni::string::to_string_t(file));
return false;
}
if (!overwrite && omni::io::file_internal::exists(new_name)) {
OMNI_DBGEV("New path already exists: ", omni::string::to_string_t(new_name));
return false;
}
std::wstring root = omni::io::wpath::get_parent_name(new_name);
if (!omni::io::wdirectory::exists(root)) {
if (create_path) {
if (!omni::io::wdirectory::create(root, true)) {
OMNI_D1_FW("could not create parent directory");
return false;
}
} else {
OMNI_D1_FW("error moving file: new path does not exist");
return false;
}
}
#if defined(OMNI_OS_WIN)
#if defined(OMNI_WIN_API)
std::wstring tf = OMNI_FILE_CHECKW_FW(tf, file, false)
std::wstring nf = OMNI_FILE_CHECKW_FW(nf, new_name, false)
BOOL ret = ::MoveFileW(tf.c_str(), nf.c_str());
if (ret == 0) {
OMNI_DV1_FW("error moving file: ", omni::string::to_string_t(omni::system::last_error_str()));
return false;
}
#else
int ret = ::_wrename(file.c_str(), new_name.c_str());
if (ret != 0) {
OMNI_DV1_FW("error moving file: ", omni::string::to_string_t(omni::system::error_str(ret)));
return false;
}
#endif
#else
int ret = ::rename(omni::string::to_string(file).c_str(), omni::string::to_string(new_name).c_str());
if (ret != 0) {
OMNI_DV1_FW("error moving file: ", omni::string::to_string_t(omni::system::error_str(ret)));
return false;
}
#endif
return omni::io::file_internal::exists(new_name);
}
template < typename STR, typename IFSTREAM >
uint64_t rd_f(const STR& file, STR& buffer)
{
IFSTREAM ifile(omni::string::to_string(file).c_str(), std::ios::binary);
if (!ifile.is_open()) { return 0; }
uint64_t length = static_cast<uint64_t>(ifile.tellg());
ifile >> buffer;
length = static_cast<uint64_t>(ifile.tellg()) - length;
ifile.close();
return length;
}
uint64_t read(const std::string& file, std::string& buffer)
{
return omni::io::file_internal::rd_f<std::string, std::ifstream>(file, buffer);
}
uint64_t read(const std::wstring& file, std::wstring& buffer)
{
return omni::io::file_internal::rd_f<std::wstring, std::wifstream>(file, buffer);
}
template < typename STR, typename IFSTREAM, typename SEQ >
uint64_t unsafe_rd(const STR& file, SEQ* buffer, uint64_t blen)
{
if ((blen == 0) || (buffer == OMNI_NULL_PTR)) { return 0; }
IFSTREAM ifile(omni::string::to_string(file).c_str(), std::ios::binary);
if (!ifile.is_open()) { return 0; }
ifile.seekg(0, ifile.end);
uint64_t length = static_cast<uint64_t>(ifile.tellg());
ifile.seekg(0, ifile.beg);
if (length > blen) { length = blen; }
ifile.read(reinterpret_cast<typename IFSTREAM::char_type*>(buffer), static_cast<std::streamsize>(length));
length = static_cast<uint64_t>(ifile.gcount());
ifile.close();
return length;
}
uint64_t unsafe_read(const std::string& file, char* buffer, uint64_t length)
{
return omni::io::file_internal::unsafe_rd<std::string, std::ifstream, char>(file, buffer, length);
}
uint64_t unsafe_read(const std::wstring& file, char* buffer, uint64_t length)
{
return omni::io::file_internal::unsafe_rd<std::string, std::ifstream, char>(omni::string::to_string(file), buffer, length);
}
uint64_t unsafe_read(const std::string& file, wchar_t* buffer, uint64_t length)
{
return omni::io::file_internal::unsafe_rd<std::string, std::ifstream, wchar_t>(file, buffer, length);
}
uint64_t unsafe_read(const std::wstring& file, wchar_t* buffer, uint64_t length)
{
return omni::io::file_internal::unsafe_rd<std::string, std::ifstream, wchar_t>(omni::string::to_string(file), buffer, length);
}
uint64_t unsafe_read(const std::string& file, uint8_t* buffer, uint64_t length)
{
return omni::io::file_internal::unsafe_rd<std::string, std::ifstream, uint8_t>(file, buffer, length);
}
uint64_t unsafe_read(const std::wstring& file, uint8_t* buffer, uint64_t length)
{
return omni::io::file_internal::unsafe_rd<std::string, std::ifstream, uint8_t>(omni::string::to_string(file), buffer, length);
}
uint64_t unsafe_read(const std::string& file, int8_t* buffer, uint64_t length)
{
return omni::io::file_internal::unsafe_rd<std::string, std::ifstream, int8_t>(file, buffer, length);
}
uint64_t unsafe_read(const std::wstring& file, int8_t* buffer, uint64_t length)
{
return omni::io::file_internal::unsafe_rd<std::string, std::ifstream, int8_t>(omni::string::to_string(file), buffer, length);
}
bool rem(const std::string& file)
{
#if defined(OMNI_OS_WIN)
#if defined(OMNI_WIN_API)
OMNI_FILE_CHECKA_FW(file, false)
if (::DeleteFileA(file.c_str()) == 0) {
OMNI_DV1_FW("error deleting file: ", omni::string::to_string_t(omni::system::last_error_str()));
return false;
}
#else
if (::_remove(file.c_str()) != 0) {
OMNI_DV1_FW("error deleting file: ", omni::system::last_error());
return false;
}
#endif
#else
if (::remove(file.c_str()) != 0) {
OMNI_DV1_FW("error deleting file: ", omni::system::last_error());
return false;
}
#endif
return !omni::io::file::exists(file);
}
bool rem(const std::wstring& file)
{
#if defined(OMNI_OS_WIN)
#if defined(OMNI_WIN_API)
std::wstring tf = OMNI_FILE_CHECKW_FW(tf, file, false)
if (::DeleteFileW(tf.c_str()) == 0) {
OMNI_DV1_FW("error deleting file: ", omni::string::to_string_t(omni::system::last_error_str()));
return false;
}
#else
if (::_wremove(file.c_str()) != 0) {
OMNI_DV1_FW("error deleting file: ", omni::system::last_error());
return false;
}
#endif
#else
if (::remove(omni::string::to_string(file).c_str()) != 0) {
OMNI_DV1_FW("error deleting file: ", omni::system::last_error());
return false;
}
#endif
return !omni::io::file::exists(file);
}
#if defined(OMNI_NON_PORTABLE)
bool set_size(const std::string& file, uint64_t size)
{
#if defined(OMNI_OS_WIN) && defined(OMNI_WIN_API)
OMNI_FILE_CHECKA_FW(file, false)
HANDLE hfile = ::CreateFileA(file.c_str(), GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
CREATE_NEW|OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hfile == INVALID_HANDLE_VALUE) {
OMNI_DBGEV("error setting file length: ", omni::system::last_error_str().c_str())
return false;
}
::SetFilePointer(hfile, size, 0, FILE_BEGIN);
::SetEndOfFile(hfile);
::CloseHandle(hfile);
#else
#if defined(OMNI_OS_WIN)
int fd = ::_open(file.c_str(), O_RDWR);
if (fd == -1) {
OMNI_DBGEV("Could not open file: ", omni::system::last_error_str().c_str())
return false;
}
errno_t ret = _chsize_s(fd, static_cast<__int64>(size));
if (ret != 0) {
OMNI_DBGEV("error setting file length: ", oomni::system::last_error_str().c_str())
::_close(fd);
return false;
}
::_close(fd);
#else
#if defined(OMNI_IO_USE_TRUNCATE)
if (OMNI_IO_FILE_TRUNCATE_FN (file.c_str(), static_cast<off_t>(size)) != 0) {
OMNI_DBGEV("error setting file length: ", omni::system::last_error())
return false;
}
#else
int fd = ::open(file.c_str(), O_RDWR);
if (fd == -1) {
OMNI_DBGEV("Could not open file: ", omni::system::last_error())
return false;
}
// TODO: if this is ::truncate (not ::ftruncate) then it expects a file path, not file handle
if (OMNI_IO_FILE_FTRUNCATE_FN (fd, static_cast<off_t>(size)) != 0) {
OMNI_DBGEV("error setting file length: ", omni::system::last_error())
::close(fd);
return false;
}
::close(fd);
#endif
#endif
#endif
return true;
}
bool set_size(const std::wstring& file, uint64_t size)
{
#if defined(OMNI_OS_WIN)
std::wstring tf = OMNI_FILE_CHECKW_FW(tf, file, false)
HANDLE hfile = ::CreateFileW(tf.c_str(), GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
CREATE_NEW|OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hfile == INVALID_HANDLE_VALUE) {
OMNI_DBGEV("error setting file length: ", omni::system::last_error_str().c_str())
return false;
}
::SetFilePointer(hfile, size, 0, FILE_BEGIN);
::SetEndOfFile(hfile);
::CloseHandle(hfile);
#else
#if defined(OMNI_OS_WIN)
int fd = ::_wopen(file.c_str(), O_RDWR);
if (fd == -1) {
OMNI_DBGEV("Could not open file: ", omni::system::last_error_str().c_str())
return false;
}
errno_t ret = _chsize_s(fd, static_cast<__int64>(size));
if (ret != 0) {
OMNI_DBGEV("error setting file length: ", ret)
::_close(fd);
return false;
}
::_close(fd);
#else
#if defined(OMNI_IO_USE_TRUNCATE)
if (OMNI_IO_FILE_TRUNCATE_FN (file.c_str(), static_cast<off_t>(size)) != 0) {
OMNI_DBGEV("error setting file length: ", omni::system::last_error())
return false;
}
#else
int fd = ::open(omni::string::to_string(file).c_str(), O_RDWR);
if (fd == -1) {
OMNI_DBGEV("Could not open file: ", omni::system::last_error())
return false;
}
if (OMNI_IO_FILE_FTRUNCATE_FN (fd, static_cast<off_t>(size)) != 0) {
OMNI_DBGEV("error setting file length: ", omni::system::last_error())
::close(fd);
return false;
}
::close(fd);
#endif
#endif
#endif
return true;
}
#endif
template < typename T, typename O >
uint64_t write_fw(const std::string& file, const T& buffer, bool append)
{
O ofile(omni::string::to_string(file).c_str(), (append ? (std::ios::binary | std::ios::app) : std::ios::binary));
uint64_t start = static_cast<uint64_t>(ofile.tellp());
uint64_t end = start;
ofile << buffer.c_str();
ofile.flush();
end = static_cast<uint64_t>(ofile.tellp());
ofile.close();
return (end - start);
}
uint64_t write(const std::string& file, const std::string& buffer, bool append)
{
return write_fw<std::string, std::ofstream>(file, buffer, append);
}
uint64_t write(const std::wstring& file, const std::wstring& buffer, bool append)
{
return write_fw<std::wstring, std::wofstream>(omni::string::to_string(file), buffer, append);
}
template < typename STR, typename OFSTREAM, typename SEQ >
uint64_t unsafe_write_fw(const STR& file, const SEQ* buffer, uint64_t length, bool append)
{
if ((length == 0) || (buffer == OMNI_NULL_PTR)) { return 0; }
OFSTREAM ofile(omni::string::to_string(file).c_str(), (append ? (std::ios::binary | std::ios::app) : std::ios::binary));
if (!ofile.is_open()) { return 0; }
uint64_t start = static_cast<uint64_t>(ofile.tellp());
uint64_t end = start;
const typename OFSTREAM::char_type* bf = reinterpret_cast<const typename OFSTREAM::char_type*>(buffer);
ofile.write(bf, static_cast<std::streamsize>(length));
ofile.flush();
if ((ofile.rdstate() & OFSTREAM::failbit) != 0) {
end = start;
OMNI_ERR_FW("Error on write: failbit set", omni::exception("Error on write: failbit set"))
} else if ((ofile.rdstate() & OFSTREAM::badbit) != 0) {
end = start;
OMNI_ERR_FW("Error on write: badbit set", omni::exception("Error on write: badbit set"))
} else {
end = static_cast<uint64_t>(ofile.tellp());
}
ofile.close();
return (end - start);
}
uint64_t unsafe_write(const std::string& file, const char* buffer, uint64_t length, bool append)
{
return unsafe_write_fw<std::string, std::ofstream, char>(file, buffer, length, append);
}
uint64_t unsafe_write(const std::wstring& file, const char* buffer, uint64_t length, bool append)
{
return unsafe_write_fw<std::wstring, std::wofstream, char>(omni::string::to_wstring(file), buffer, length, append);
}
uint64_t unsafe_write(const std::string& file, const wchar_t* buffer, uint64_t length, bool append)
{
return unsafe_write_fw<std::string, std::ofstream, wchar_t>(file, buffer, length, append);
}
uint64_t unsafe_write(const std::wstring& file, const wchar_t* buffer, uint64_t length, bool append)
{
return unsafe_write_fw<std::wstring, std::wofstream, wchar_t>(file, buffer, length, append);
}
uint64_t unsafe_write(const std::string& file, const uint8_t* buffer, uint64_t length, bool append)
{
return unsafe_write_fw<std::string, std::ofstream, uint8_t>(file, buffer, length, append);
}
uint64_t unsafe_write(const std::wstring& file, const uint8_t* buffer, uint64_t length, bool append)
{
return unsafe_write_fw<std::wstring, std::wofstream, uint8_t>(omni::string::to_wstring(file), buffer, length, append);
}
uint64_t unsafe_write(const std::string& file, const int8_t* buffer, uint64_t length, bool append)
{
return unsafe_write_fw<std::string, std::ofstream, int8_t>(file, buffer, length, append);
}
uint64_t unsafe_write(const std::wstring& file, const int8_t* buffer, uint64_t length, bool append)
{
return unsafe_write_fw<std::wstring, std::wofstream, int8_t>(file, buffer, length, append);
}
template < typename STR, typename OFSTREAM >
uint64_t write_line_fw(const std::string& file, const STR& buffer, bool append)
{
OFSTREAM ofile(omni::string::to_string(file).c_str(), (append ? (std::ios::binary | std::ios::app) : std::ios::binary));
uint64_t start = static_cast<uint64_t>(ofile.tellp());
uint64_t end = start;
ofile << buffer.c_str() << std::endl;
ofile.flush();
end = static_cast<uint64_t>(ofile.tellp());
ofile.close();
return (end - start);
}
uint64_t write_line(const std::string& file, const std::string& buffer, bool append)
{
return write_line_fw<std::string, std::ofstream>(file, buffer, append);
}
uint64_t write_line(const std::wstring& file, const std::wstring& buffer, bool append)
{
return write_line_fw<std::wstring, std::wofstream>(omni::string::to_string(file), buffer, append);
}
template < typename STR, typename OFSTREAM, typename SEQ >
uint64_t unsafe_write_line_fw(const STR& file, const SEQ* buffer, uint64_t length, bool append)
{
if ((length == 0) || (buffer == OMNI_NULL_PTR)) { return 0; }
OFSTREAM ofile(omni::string::to_string(file).c_str(), (append ? (std::ios::binary | std::ios::app) : std::ios::binary));
uint64_t start = static_cast<uint64_t>(ofile.tellp());
uint64_t end = start;
const typename OFSTREAM::char_type* bf = reinterpret_cast<const typename OFSTREAM::char_type*>(buffer);
ofile.write(bf, static_cast<std::streamsize>(length));
ofile << std::endl;
ofile.flush();
if ((ofile.rdstate() & OFSTREAM::failbit) != 0) {
end = start;
OMNI_ERR_FW("Error on write: failbit set", omni::exception("Error on write: failbit set"))
} else if ((ofile.rdstate() & OFSTREAM::badbit) != 0) {
end = start;
OMNI_ERR_FW("Error on write: badbit set", omni::exception("Error on write: badbit set"))
} else {
end = static_cast<uint64_t>(ofile.tellp());
}
ofile.close();
return (end - start);
}
uint64_t unsafe_write_line(const std::string& file, const char* buffer, uint64_t length, bool append)
{
return unsafe_write_line_fw<std::string, std::ofstream, char>(file, buffer, length, append);
}
uint64_t unsafe_write_line(const std::wstring& file, const char* buffer, uint64_t length, bool append)
{
return unsafe_write_line_fw<std::wstring, std::wofstream, char>(file, buffer, length, append);
}
uint64_t unsafe_write_line(const std::string& file, const wchar_t* buffer, uint64_t length, bool append)
{
return unsafe_write_line_fw<std::string, std::ofstream, wchar_t>(file, buffer, length, append);
}
uint64_t unsafe_write_line(const std::wstring& file, const wchar_t* buffer, uint64_t length, bool append)
{
return unsafe_write_line_fw<std::wstring, std::wofstream, wchar_t>(file, buffer, length, append);
}
uint64_t unsafe_write_line(const std::string& file, const uint8_t* buffer, uint64_t length, bool append)
{
return unsafe_write_line_fw<std::string, std::ofstream, uint8_t>(file, buffer, length, append);
}
uint64_t unsafe_write_line(const std::wstring& file, const uint8_t* buffer, uint64_t length, bool append)
{
return unsafe_write_line_fw<std::wstring, std::wofstream, uint8_t>(file, buffer, length, append);
}
uint64_t unsafe_write_line(const std::string& file, const int8_t* buffer, uint64_t length, bool append)
{
return unsafe_write_line_fw<std::string, std::ofstream, int8_t>(file, buffer, length, append);
}
uint64_t unsafe_write_line(const std::wstring& file, const int8_t* buffer, uint64_t length, bool append)
{
return unsafe_write_line_fw<std::wstring, std::wofstream, int8_t>(file, buffer, length, append);
}
} } }
#endif // OMNI_IO_FILE_INTERNAL_FW
bool omni::io::OMNI_PATH_FW::copy(const OMNI_STRING_T_FW& file, const OMNI_STRING_T_FW& new_name, const omni::io::options& io_ops)
{
if (file.empty() || new_name.empty()) {
OMNI_ERR_RETV_FW(OMNI_PATH_EMPTY_STR, omni::exceptions::path_exception(OMNI_PATH_EMPTY_STR), false);
}
if (!omni::io::file_internal::exists(file)) {
OMNI_ERRV_RETV_FW(OMNI_FILE_NOT_FOUND_STR, omni::string::to_string_t(file), omni::exceptions::file_not_found(omni::string::to_string(file)), false);
}
bool overwrite = ((io_ops & omni::io::options::OVERWRITE) == omni::io::options::OVERWRITE);
bool create_path = ((io_ops & omni::io::options::CREATE_PATH) == omni::io::options::CREATE_PATH);
if (!overwrite && omni::io::file_internal::exists(new_name)) {
OMNI_DBGEV("New path already exists: ", omni::string::to_string_t(new_name));
return false;
}
OMNI_STRING_T_FW root = omni::io::path::get_parent_name(new_name);
if (!omni::io::directory::exists(root)) {
if (create_path) {
if (!omni::io::directory::create(root, true)) {
OMNI_D1_FW("could not create parent directory");
return false;
}
} else {
OMNI_D1_FW("error copying file: new path does not exist");
return false;
}
}
if (omni::io::file_internal::copy(file, new_name)) {
return omni::io::file_internal::exists(new_name);
}
return false;
}
OMNI_STRING_T_FW omni::io::OMNI_PATH_FW::get_contents(const OMNI_STRING_T_FW& file)
{
if (!omni::io::file_internal::exists(file)) {
OMNI_ERRV_RETV_FW("file does not exist: ", omni::string::to_string_t(file), omni::exceptions::path_exception("File does not exist", omni::string::to_string(file)), OMNI_STRING_T_FW())
}
return omni::io::file_internal::get_contents(file);
}
uint64_t omni::io::OMNI_PATH_FW::get_size(const OMNI_STRING_T_FW& file)
{
if (!omni::io::file_internal::exists(file)) {
OMNI_ERRV_RETV_FW("file does not exist: ", omni::string::to_string_t(file), omni::exceptions::path_exception("File does not exist", omni::string::to_string(file)), 0)
}
return omni::io::file_internal::get_size(file);
}
bool omni::io::OMNI_PATH_FW::move(const OMNI_STRING_T_FW& file, const OMNI_STRING_T_FW& new_name, const omni::io::options& io_ops)
{
bool overwrite = ((io_ops & omni::io::options::OVERWRITE) == omni::io::options::OVERWRITE);
bool create_path = ((io_ops & omni::io::options::CREATE_PATH) == omni::io::options::CREATE_PATH);
if (!omni::io::file_internal::exists(file)) {
OMNI_ERRV_RETV_FW("file does not exist: ", omni::string::to_string_t(file), omni::exceptions::path_exception("File does not exist", omni::string::to_string(file)), false)
}
if (!overwrite && omni::io::file_internal::exists(new_name)) {
OMNI_ERRV_RETV_FW("file already exists: ", omni::string::to_string_t(new_name), omni::exceptions::path_exception("File already exist", omni::string::to_string(new_name)), false)
}
OMNI_STRING_T_FW root = omni::io::path::get_parent_name(new_name);
if (!omni::io::directory::exists(root)) {
if (create_path) {
if (!omni::io::directory::create(root, true)) {
OMNI_D1_FW("could not create parent directory");
return false;
}
} else {
OMNI_D1_FW("error copying file: new path does not exist");
return false;
}
}
return omni::io::file_internal::mv(file, new_name, io_ops);
}
bool omni::io::OMNI_PATH_FW::remove(const OMNI_STRING_T_FW& file)
{
if (!omni::io::file_internal::exists(file)) {
OMNI_DV1_FW("file does not exists: ", omni::string::to_string_t(file));
return true;
}
return omni::io::file_internal::rem(file);
}
#if defined(OMNI_NON_PORTABLE)
bool omni::io::OMNI_PATH_FW::set_size(const OMNI_STRING_T_FW& file, uint64_t size)
{
// The file must exist before this function can continue
if (!omni::io::file_internal::exists(file)) {
if (!omni::io::file_internal::create(file, true)) {
OMNI_DBGE("could not create file")
return false;
}
}
if (!omni::io::file_internal::set_size(file, size)) { return false; }
// DEV_NOTE: the following comments are here for instructional purpose
/*
// This function CAN destroy data. This functions uses API to extend or shorten
// a file. If data is in the file and you extend the file, the data will stay
// in place and the file length will simple be extended. If you shorten the file
// the data at the end of the file will be freed (in other words, it will not be deleted
// simply not associated with a file).
// DEV_NOTE: It is possible, though uncommon, for an extended file to contain random
// data where the file has been extended. This is typical of a sparse file. It is common
// in Unix/Linux but no so much in Windows. Note that the reason we do not just write out
// length worth of null is because depending on length this could take a long time.
// No pun intended. Using the API to create a sparse file, it simply tells the FAT
// (file allocation table) that file X is length in size
*/
return omni::io::OMNI_PATH_FW::get_size(file) == size;
}
#endif
bool omni::io::OMNI_PATH_FW::copy(const OMNI_STRING_T_FW& file, const OMNI_STRING_T_FW& new_name) { return omni::io::OMNI_PATH_FW::copy(file, new_name, omni::io::options::NONE); }
bool omni::io::OMNI_PATH_FW::create(const OMNI_STRING_T_FW& file, const omni::io::options& io_ops) { return omni::io::file_internal::create(file, io_ops); }
bool omni::io::OMNI_PATH_FW::create(const OMNI_STRING_T_FW& file) { return omni::io::OMNI_PATH_FW::create(file, omni::io::options::NONE); }
bool omni::io::OMNI_PATH_FW::exists(const OMNI_STRING_T_FW& file) { return omni::io::file_internal::exists(file); }
bool omni::io::OMNI_PATH_FW::exist(const OMNI_STRING_T_FW& file) { return omni::io::OMNI_PATH_FW::exists(file); }
bool omni::io::OMNI_PATH_FW::move(const OMNI_STRING_T_FW& file, const OMNI_STRING_T_FW& new_name) { return omni::io::OMNI_PATH_FW::move(file, new_name, omni::io::options::NONE); }
bool omni::io::OMNI_PATH_FW::rename(const OMNI_STRING_T_FW& file, const OMNI_STRING_T_FW& new_name, const omni::io::options& io_ops) { return omni::io::OMNI_PATH_FW::move(file, new_name, io_ops); }
bool omni::io::OMNI_PATH_FW::rename(const OMNI_STRING_T_FW& file, const OMNI_STRING_T_FW& new_name) { return omni::io::OMNI_PATH_FW::rename(file, new_name, omni::io::options::NONE); }
uint64_t omni::io::OMNI_PATH_FW::read(const OMNI_STRING_T_FW& file, OMNI_STRING_T_FW& buffer) { return omni::io::file_internal::read(file, buffer); }
uint64_t omni::io::OMNI_PATH_FW::unsafe_read(const OMNI_STRING_T_FW& file, char* buffer, uint64_t length) { return omni::io::file_internal::unsafe_read(file, buffer, length); }
uint64_t omni::io::OMNI_PATH_FW::unsafe_read(const OMNI_STRING_T_FW& file, wchar_t* buffer, uint64_t length) { return omni::io::file_internal::unsafe_read(file, buffer, length); }
uint64_t omni::io::OMNI_PATH_FW::unsafe_read(const OMNI_STRING_T_FW& file, uint8_t* buffer, uint64_t length) { return omni::io::file_internal::unsafe_read(file, buffer, length); }
uint64_t omni::io::OMNI_PATH_FW::unsafe_read(const OMNI_STRING_T_FW& file, int8_t* buffer, uint64_t length) { return omni::io::file_internal::unsafe_read(file, buffer, length); }
uint64_t omni::io::OMNI_PATH_FW::write(const OMNI_STRING_T_FW& file, const OMNI_STRING_T_FW& buffer) { return omni::io::file_internal::write(file, buffer, false); }
uint64_t omni::io::OMNI_PATH_FW::unsafe_write(const OMNI_STRING_T_FW& file, const char* buffer, uint64_t length) { return omni::io::file_internal::unsafe_write(file, buffer, length, false); }
uint64_t omni::io::OMNI_PATH_FW::unsafe_write(const OMNI_STRING_T_FW& file, const wchar_t* buffer, uint64_t length) { return omni::io::file_internal::unsafe_write(file, buffer, length, false); }
uint64_t omni::io::OMNI_PATH_FW::unsafe_write(const OMNI_STRING_T_FW& file, const uint8_t* buffer, uint64_t length) { return omni::io::file_internal::unsafe_write(file, buffer, length, false); }
uint64_t omni::io::OMNI_PATH_FW::unsafe_write(const OMNI_STRING_T_FW& file, const int8_t* buffer, uint64_t length) { return omni::io::file_internal::unsafe_write(file, buffer, length, false); }
uint64_t omni::io::OMNI_PATH_FW::write_line(const OMNI_STRING_T_FW& file, const OMNI_STRING_T_FW& buffer) { return omni::io::file_internal::write_line(file, buffer, false); }
uint64_t omni::io::OMNI_PATH_FW::unsafe_write_line(const OMNI_STRING_T_FW& file, const char* buffer, uint64_t length) { return omni::io::file_internal::unsafe_write_line(file, buffer, length, false); }
uint64_t omni::io::OMNI_PATH_FW::unsafe_write_line(const OMNI_STRING_T_FW& file, const wchar_t* buffer, uint64_t length) { return omni::io::file_internal::unsafe_write_line(file, buffer, length, false); }
uint64_t omni::io::OMNI_PATH_FW::unsafe_write_line(const OMNI_STRING_T_FW& file, const uint8_t* buffer, uint64_t length) { return omni::io::file_internal::unsafe_write_line(file, buffer, length, false); }
uint64_t omni::io::OMNI_PATH_FW::unsafe_write_line(const OMNI_STRING_T_FW& file, const int8_t* buffer, uint64_t length) { return omni::io::file_internal::unsafe_write_line(file, buffer, length, false); }
uint64_t omni::io::OMNI_PATH_FW::write(const OMNI_STRING_T_FW& file, const OMNI_STRING_T_FW& buffer, bool append) { return omni::io::file_internal::write(file, buffer, append); }
uint64_t omni::io::OMNI_PATH_FW::unsafe_write(const OMNI_STRING_T_FW& file, const char* buffer, uint64_t length, bool append) { return omni::io::file_internal::unsafe_write(file, buffer, length, append); }
uint64_t omni::io::OMNI_PATH_FW::unsafe_write(const OMNI_STRING_T_FW& file, const wchar_t* buffer, uint64_t length, bool append) { return omni::io::file_internal::unsafe_write(file, buffer, length, append); }
uint64_t omni::io::OMNI_PATH_FW::unsafe_write(const OMNI_STRING_T_FW& file, const uint8_t* buffer, uint64_t length, bool append) { return omni::io::file_internal::unsafe_write(file, buffer, length, append); }
uint64_t omni::io::OMNI_PATH_FW::unsafe_write(const OMNI_STRING_T_FW& file, const int8_t* buffer, uint64_t length, bool append) { return omni::io::file_internal::unsafe_write(file, buffer, length, append); }
uint64_t omni::io::OMNI_PATH_FW::write_line(const OMNI_STRING_T_FW& file, const OMNI_STRING_T_FW& buffer, bool append) { return omni::io::file_internal::write_line(file, buffer, append); }
uint64_t omni::io::OMNI_PATH_FW::unsafe_write_line(const OMNI_STRING_T_FW& file, const char* buffer, uint64_t length, bool append) { return omni::io::file_internal::unsafe_write_line(file, buffer, length, append); }
uint64_t omni::io::OMNI_PATH_FW::unsafe_write_line(const OMNI_STRING_T_FW& file, const wchar_t* buffer, uint64_t length, bool append) { return omni::io::file_internal::unsafe_write_line(file, buffer, length, append); }
uint64_t omni::io::OMNI_PATH_FW::unsafe_write_line(const OMNI_STRING_T_FW& file, const uint8_t* buffer, uint64_t length, bool append) { return omni::io::file_internal::unsafe_write_line(file, buffer, length, append); }
uint64_t omni::io::OMNI_PATH_FW::unsafe_write_line(const OMNI_STRING_T_FW& file, const int8_t* buffer, uint64_t length, bool append) { return omni::io::file_internal::unsafe_write_line(file, buffer, length, append); }