acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
_impl_path.h
1//
2// Created by camilo on 23/12/22.
3//
4#pragma once
5
6
7#include "acme/filesystem/filesystem/file_dialog.h"
8#include "acme/filesystem/filesystem/windows_path.h"
9#include "acme/prototype/string/scoped_string_base.h"
10
11
12namespace file
13{
14
15
16 // inline path path::operator/(const path &path) const
17 // {
18 //
19 // return ::transfer(*this / ::scoped_string(path));
20 //
21 // }
22
23
24 // inline path path::operator/(const_char_pointer psz) const
25 // {
26 //
27 // return ::transfer(*this / ::scoped_string(scopedstr));
28 //
29 // }
30
31
32 // inline path path::operator/(const ::scoped_string & scopedstr) const
33 // {
34 //
35 // return ::transfer(*this / ::scoped_string(str));
36 //
37 // }
38
39
40} // namespace file
41
42
43namespace file
44{
45
46
47 inline path_meta::path_meta(enum_path epath, ::i64 iSize, e_type etype, ::i64 iName, character_count iBasePathLength, const ::file::e_flag & eflag)
48 {
49
50 m_epath = epath;
51 m_iSize = iSize;
52 m_etype = etype;
53 m_iName = (character_count)iName;
54 m_iBasePathLength = iBasePathLength;
55 m_flags = eflag;
56
57 }
58
59
60 //template < typename ITERATOR_TYPE, ::i32 t_size >
61 //inline path::path(const const_string_range_static_array < ITERATOR_TYPE, t_size >& a, enum_path epath, e_type etype, bool bNormalize, ::i64 iSize) :
62 // path((const ::ansi_string&)a, epath, etype, bNormalize, iSize)
63 //{
64
65
66 //}
67
68
69
70
71 //inline path::path(const ::wd16_string & wd16str, enum_path epath, e_type etype, bool bNormalizePath, ::i64 iSize) :
72 // path(::string(wd16str), epath, etype, bNormalizePath, iSize)
73 //{
74
75
76 //}
77
78
79 //template < typename ITERATOR_TYPE >
80 //inline path::path(const ::range < ITERATOR_TYPE > & range, enum_path epath, e_type etype, bool bNormalizePath, ::i64 iSize) :
81 // path(::string(range), epath, etype, bNormalizePath, iSize)
82 //{
83
84
85 //}
86
87
88 //inline path::path(const_char_pointer pansisz, enum_path epath, e_type etype, bool bNormalizePath, ::i64 iSize) :
89 // path(::ansi_string(pansisz), epath, etype, bNormalizePath, iSize)
90 //{
91
92
93 //}
94
95
96 //inline path::path(const ::wd16_character * pwd16sz, enum_path epath, e_type etype, bool bNormalizePath, ::i64 iSize) :
97 // path(::string(pwd16sz), epath, etype, bNormalizePath, iSize)
98 //{
99
100
101 //}
102
103
104 //inline path::path(const ::wd32_character * pwd32sz, enum_path epath, e_type etype, bool bNormalizePath, ::i64 iSize) :
105 // path(::string(pwd32sz), epath, etype, bNormalizePath, iSize)
106 //{
107
108
109 //}
110
111
112 inline path_meta::~path_meta()
113 {
114
115
116 }
117
118
119 //inline path::path(const ::payload& payload) :
120 // path(payload.file_path())
121 //{
122
123
124 //}
125
126
127 //inline path::path(const ::property& property) :
128 // path(property.file_path())
129 //{
130
131
132 //}
133
134
135 //inline path::path(const ::atom& atom) :
136 // path(atom.string())
137 //{
138
139
140 //}
141
142 // path::path(nullptr_t)
143 // {
144 //
145 // m_epath = path_file;
146 //
147 // }
148
149
150 // path::path(e_path epath)
151 // {
152 //
153 // m_epath = epath;
154 //
155 // }
156 //namespace file
157 //{
158
159 //inline path::path(const path& path) :
160 // string((const string&)path),
161 // path_meta(path)
162 //{
163
164 //}
165
166
167 //inline path::path(const path_object& path) :
168 // ::file::path((const ::file::path&)path)
169 //{
170
171 //}
172
173
174 //
175 //} // namespace file
176 //
177
178
179 // path::path(const wide_character * pwsz, character_count iCount, e_path epath, e_type etype, bool bNormalizePath, ::i64 iSize) :
180 // string(pwsz, iCount),
181 // path_meta(epath, iSize, iDir)
182 // {
183 //
184 // if (m_epath == path_none)
185 // {
186 //
187 // m_epath = file_path_get_type(*this, epath);
188 //
189 // }
190 //
191 // if (bNormalizePath)
192 // {
193 //
194 // bool bCertainlySyntathicallyDir = normalize_path_inline(*this, m_epath);
195 //
196 // if (bCertainlySyntathicallyDir)
197 // {
198 //
199 // m_iDir = 1;
200 //
201 // }
202 // else
203 // {
204 //
205 // m_iDir = iDir;
206 //
207 // }
208 //
209 // }
210 //
211 // }
212
213
214
215 // path::path(const atom & atom,e_path epath, e_type etype) :
216 // path(string(atom), epath, iDir)
217 // {
218 //
219 // }
220
221
222 // path::path(const ::payload & payload, e_path epath, e_type etype) :
223 // path(payload.get_string(), epath, iDir)
224 // {
225 //
226 //
227 // }
228
229
230 // path::path(const path & path) :
231 // ::ansi_string((const string &)path),
232 // path_meta((path_meta &)path),
233 // path_os((path_os &) path)
234 // {
235 //
236 // }
237
238
239 // path::path(path && path) :
240 // string(::transfer(path)),
241 // path_meta((path_meta &) path),
242 // path_os(::transfer(path))
243 // {
244 //
245 // }
246
247
248 // path::path(const ::scoped_string & scopedstr, e_path epath, e_type etype):
249 // path(string(scopedstr), epath, iDir)
250 // {
251 //
252 // }
253
254 // path::path(const wide_character * psz, e_path epath, e_type etype) :
255 // path(string(scopedstr), epath, iDir)
256 // {
257 //
258 // }
259
260
261 // path::path(const wstring & wstr, e_path epath, e_type etype):
262 // path(string(wstr), epath, iDir)
263 // {
264 //
265 // }
266
267 inline path::~path() noexcept
268 {
269
270
271 }
272
273
274 // bool path::is_equal(const path & path) const
275 // {
276 //
277 //
278 //#ifdef WINDOWS
279 //
280 // if (((const string &)*this).case_insensitive_order((const string &)path) == 0) // undoubtely eaqual...
281 // return true;
282 //
283 //#else
284 //
285 // if (((const string &)*this).operator == ((const string &)path)) // undoubtely eaqual...
286 // return true;
287 //
288 //#endif
289 //
290 // return false;
291 //
292 // // find extend equalitys..
293 //
294 // ::file::path_array_base patha1;
295 //
296 // split(patha1);
297 //
298 // ::file::path_array_base patha2;
299 //
300 // path.split(patha2);
301 //
302 // if(patha1.get_size() == patha2.get_size())
303 // {
304 //
305 // for(::collection::index i = 0; i < patha1.get_size(); i++)
306 // {
307 //
308 // if(patha1[i].::ansi_string::operator!=(patha2[i]))
309 // {
310 //
311 // goto there_s_difference_in_this_step_1;
312 //
313 // }
314 //
315 // }
316 //
317 // return true;
318 //
319 // }
320 //
321 // there_s_difference_in_this_step_1:
322 //
323 //
324 // return false;
325 //
326 // }
327
328
329 //inline void path::split(string_array_base& patha) const
330 //{
331
332 // ascendants_name(patha);
333
334 //}
335
336
337
338
339 //inline string path::name(::collection::index i) const
340 //{
341
342
343 // string_array_base patha;
344
345 // ascendants_name(patha);
346
347 // if (i < 0)
348 // {
349
350 // i += patha.get_size();
351
352 // }
353
354
355 // if (i < 0)
356 // {
357
358 // return "";
359
360 // }
361
362 // if (i >= patha.get_size())
363 // {
364
365 // return "";
366
367 // }
368
369 // return patha[i];
370
371 //}
372
373
374 //inline string_array_base& path::ascendants_name(string_array_base& straParam) const
375 //{
376
377 // string strPath = *this;
378
379 // if (strPath == "/")
380 // {
381
382 // straParam.add("/");
383
384 // return straParam;
385
386 // }
387
388 // character_count iFirstColon = find(':');
389 // character_count iFirstSlash = find('/');
390 // character_count iSecondSlash = find('/', iFirstSlash + 1);
391
392 // if (iFirstColon > 0 && iFirstSlash == iFirstColon + 1 && iSecondSlash == iFirstSlash + 1)
393 // {
394
395 // ::file::path path = Left(iSecondSlash + 1);
396
397 // straParam.add(path);
398
399 // strPath = Mid(iSecondSlash + 1);
400
401 // }
402
403 // bool bWin1 = strPath.begins_eat("\\\\?\\");
404
405 // auto pFind = 0;
406 // while (true)
407 // {
408
409 // index iFind1 = strPath.find('/', iFind);
410 // index iFind2 = strPath.find('\\', iFind);
411 // index iFind3 = minimum_non_negative(iFind1, iFind2);
412 // if (iFind3 < 0)
413 // {
414 // string str = strPath(pFind);
415 // straParam.add(str);
416 // break;
417 // }
418 // string str = strPath.substr(iFind, iFind3 - iFind);
419 // straParam.add(str);
420 // iFind = iFind3 + 1;
421 // }
422
423
424 // if (bWin1)
425 // {
426 // straParam[0] = "\\\\?\\" + straParam[0];
427 // }
428 // else if (this->case_insensitive_begins("/"))
429 // {
430 // straParam[0] = "/" + straParam[0];
431 // }
432 // else if (this->case_insensitive_begins("\\\\"))
433 // {
434 // straParam[0] = "\\\\" + straParam[0];
435 // }
436
437 // return straParam;
438
439 //}
440
441
442 inline path path::folder(::i32 i) const
443 {
444
445 ::file::path path(*this);
446
447 while (i > 0)
448 {
449
450 path = path.folder();
451
452 i--;
453
454 }
455
456 return path;
457
458 }
459
460
461 inline path& path::ascend()
462 {
463
464 return *this = parent();
465
466 }
467
468
469 inline path& path::ascend(::i32 i)
470 {
471
472 while (i > 0)
473 {
474
475 ascend();
476
477 i--;
478
479 }
480
481 return *this;
482
483 }
484
485
486 // inline path& path::operator += (const path& path)
487 // {
488 //
489 // string str = path;
490 //
491 // str.trim_left("\\/");
492 //
493 // string::operator += (str);
494 //
495 // return *this;
496 //
497 // }
498
499
500 //inline path& path::operator += (const ::const_ansi_range & range)
501 //{
502
503 // string str(range);
504
505 // str.trim_left("\\/");
506
507 // string strThis = *this;
508
509 // string ::operator = (file_path_normalize(strThis + str, m_epath));
510
511 // return *this;
512
513 //}
514
515
516 inline path& path::operator += (const ::scoped_string& scopedstr)
517 {
518
519 auto pathThis = *this;
520
521 ::string::operator = (file_path_normalize(((const ::string&)pathThis) + scopedstr, this->m_epath));
522
523 return *this;
524
525 }
526
527
528
529 // path_array path::operator / (const string_array_base & stra) const
530 // {
531 //
532 // path_array patha;
533 //
534 // for (auto str : stra)
535 // {
536 //
537 // patha.add(*this / str);
538 //
539 // }
540 //
541 // return patha;
542 //
543 // }
544
545
546
547
548// inline path path::operator / (const ::ansi_string& str) const
549// {
550//
551// return operator /(::file::path(str));
552//
553// }
554//
555
556 //template < prototype_atom ATOM >
557 //inline path path::operator / (const ATOM & atom) const
558 //{
559
560 // return operator /(::file::path(atom));
561
562 //}
563
564
565// inline path path::operator / (const ::scoped_string & scopedstr) const
566// {
567//
568// return slashed_path(scopedstr);
569//
570// }
571
572// inline path& path::operator /= (const path& path)
573// {
574//
575// string strPath;
576//
577// strPath = string(*this);
578//
579// string str = path;
580//
581// if (strPath.right(3) == "://")
582// {
583//
584// return operator = (::file::path(strPath + str, m_epath));
585//
586// }
587//
588// if (strPath.is_empty())
589// {
590//
591// strPath = separator();
592//
593// }
594// else if (strPath.size() == 1 && strPath[0] == separator())
595// {
596//
597// }
598// else
599// {
600//
601// strPath += separator();
602//
603// str.trim_left("\\/");
604//
605// }
606//
607// return operator = (::file::path(strPath + str, m_epath));
608//
609// }
610
611
612// inline path& path::operator /= (const ::ansi_string& str)
613// {
614//
615// return operator /=(::file::path(str));
616//
617// }
618//
619//
620// inline path & path::operator /= (const ::inline_number_string & inlinenumberstring)
621// {
622//
623// return operator /=(::file::path(::string(inlinenumberstring)));
624//
625// }
626
627
628 // inline path path::operator / (const ::atom & atom)
629 // {
630 //
631 // return operator /(::file::path(atom));
632 //
633 // }
634
635
636
637
638 //::file::path path::replace_extension(const ::scoped_string & scopedstrNewExtension, const ::scoped_string & scopedstrOldExtension)
639 //{
640
641 // string strNewExtension(scopedstrNewExtension);
642
643 // strNewExtension.case_insensitive_begins_eat(".");
644
645 // string strOldExtension(scopedstrOldExtension);
646
647 // strOldExtension.case_insensitive_begins_eat(".");
648
649 // ::file::path path(*this);
650
651 // path.case_insensitive_ends_eat(strOldExtension);
652
653 // path += strNewExtension;
654
655 // return path;
656
657 //}
658
659
660 inline void path::set_all_extensions(const ::scoped_string& scopedstrExtension)
661 {
662
663 string strExtension(scopedstrExtension);
664
665 strExtension.case_insensitive_begins_eat(".");
666
667 auto range = find_all_extensions();
668
669 if (range.begin() >= this->begin() + 1)
670 {
671
672 this->operator = ((*this)(0, range.begin()) + strExtension);
673
674 }
675 else
676 {
677
678 this->operator += ("." + strExtension);
679
680 }
681
682 }
683
684
685 inline void path::set_final_extension(const ::scoped_string& scopedstrExtension)
686 {
687
688 string strExtension(scopedstrExtension);
689
690 strExtension.case_insensitive_begins_eat(".");
691
692 auto range = find_final_extension();
693
694 if (range.begin() >= this->begin() + 1)
695 {
696
697 this->operator = ((*this)(0, range.begin()) + strExtension);
698
699 }
700 else
701 {
702
703 this->operator += ("." + strExtension);
704
705 }
706
707 }
708
709
710 inline void path::set_extension_if_no_extension(const ::scoped_string& scopedstrExtension)
711 {
712
713 if (this->final_extension().is_empty())
714 {
715
716 auto p = scopedstrExtension.skip('.');
717
718 if (::has_character(p))
719 {
720
721 this->operator = (((::ansi_string&)*this) + "." + scopedstrExtension(p));
722
723 }
724
725 }
726
727 }
728
729
730 inline void path::defer_set_extension(const ::string_array_base& straPreserveExtensions)
731 {
732
733 defer_set_extension(straPreserveExtensions, {});
734
735 }
736
737
738
739 inline void path::defer_set_extension(const ::string_array_base& straPreserveExtensions, const ::string_array_base& straRelatedExtensions)
740 {
741
742 if (straPreserveExtensions.is_empty())
743 {
744
745 throw ::exception(error_bad_argument);
746
747 }
748
749 ::string str(*this);
750
751 bool bErased;
752
753 ::string strRearSuffix;
754
755 do
756 {
757
758 bErased = false;
759
760 for (auto& strExtension : straPreserveExtensions)
761 {
762
763 if (strRearSuffix.has_character())
764 {
765
766 bErased = str.case_insensitive_ends_eat("." + strExtension);
767
768 }
769 else
770 {
771
772 bErased = str.ends_erase_get_erased(strRearSuffix, "." + strExtension);
773
774 strRearSuffix.begins_eat(".");
775
776 }
777
778 if (bErased)
779 {
780
781 break;
782
783 }
784
785 }
786
787 if (!bErased)
788 {
789
790 for (auto& strRelatedExtension : straRelatedExtensions)
791 {
792
793 bErased = str.case_insensitive_ends_eat("." + strRelatedExtension);
794
795 if (bErased)
796 {
797
798 break;
799
800 }
801
802 }
803
804 }
805
806 } while (bErased);
807
808 if (strRearSuffix.has_character())
809 {
810
811 str += "." + strRearSuffix;
812
813 }
814 else
815 {
816
817 str += "." + straPreserveExtensions.first();
818
819 }
820
821 this->operator =(str);
822
823 }
824
825
826 inline ::file::path path::with_all_extensions(const ::scoped_string& scopedstrExtension) const
827 {
828
829 ::file::path path(*this);
830
831 path.set_all_extensions(scopedstrExtension);
832
833 return ::transfer(path);
834
835 }
836
837
838 inline ::file::path path::with_final_extension(const ::scoped_string& scopedstrExtension) const
839 {
840
841 ::file::path path(*this);
842
843 path.set_final_extension(scopedstrExtension);
844
845 return ::transfer(path);
846
847 }
848
849
850 inline ::file::path path::with_extension_if_no_extension(const ::scoped_string& scopedstrExtension) const
851 {
852
853 ::file::path path(*this);
854
855 path.set_extension_if_no_extension(scopedstrExtension);
856
857 return ::transfer(path);
858
859 }
860
861
862 inline ::file::path path::with_deferred_extension(const ::string_array_base& straPreserveExtensions) const
863 {
864
865 return with_deferred_extension(straPreserveExtensions, {});
866
867 }
868
869
870 inline ::file::path path::with_deferred_extension(const ::file::file_dialog* pfiledialog) const
871 {
872
873 return with_deferred_extension(
874 pfiledialog->m_filedialogfilter[0].get_preserve_extensions(),
875 pfiledialog->m_filedialogfilter.get_all_related_extensions());
876
877 }
878
879
880 inline ::file::path path::with_deferred_extension(const ::string_array_base& straPreserveExtensions, const ::string_array_base& straRelatedExtensions) const
881 {
882
883 ::file::path path(*this);
884
885 path.defer_set_extension(straPreserveExtensions, straRelatedExtensions);
886
887 return ::transfer(path);
888
889 }
890
891
892 inline ::windows_path path::windows_path() const
893 {
894
895 return *this;
896
897 }
898
899
900 inline void path::set_type(enum_path epath)
901 {
902
903 if (epath != m_epath)
904 {
905
906 m_epath = epath;
907
908 ::ansi_string ::operator = (file_path_normalize(*this, m_epath));
909
910 }
911
912 }
913
914
915 inline path& path::set_file_path(const ::scoped_string& scopedstrFile)
916 {
917
918 operator = (scopedstrFile);
919
920 set_file_path();
921
922 return *this;
923
924 }
925
926
927 inline path& path::set_folder_path(const ::scoped_string& scopedstrFolder)
928 {
929
930 operator = (scopedstrFolder);
931
932 folder();
933
934 return *this;
935
936 }
937
938
939 inline path& path::set_file_path()
940 {
941
942 m_etype = ((m_etype | e_type_file2) & ~e_type_folder2);
943
944 return *this;
945
946 }
947
948
949 inline path& path::set_folder_path()
950 {
951
952 m_etype = ((m_etype | e_type_folder2) & ~e_type_file2);
953
954 return *this;
955
956 }
957
958
959 inline path& path::set_existent_file()
960 {
961
962 set_file_path();
963
964 set_existent();
965
966 return *this;
967
968 }
969
970
971 inline path& path::set_existent()
972 {
973
974 m_etype = ((m_etype | e_type_exists) & ~e_type_doesnt_exist);
975
976 return *this;
977
978 }
979
980
981 inline path& path::set_existent_folder()
982 {
983
984 set_folder_path();
985
986 set_existent();
987
988 return *this;
989
990 }
991
992
993 inline path& path::operator = (const ::file::path& path)
994 {
995
996 if (&path != this)
997 {
998
999 string::operator = ((const string&)path);
1000 *((path_meta*)this) = (const path_meta&)path;
1001 //#ifdef WINDOWS_DESKTOP
1002 // m_idlist = path.m_idlist;
1003 //#endif
1004
1005 }
1006
1007 return *this;
1008
1009
1010 }
1011
1012
1013 // inline path& path::operator = (const ::ansi_string& str)
1014 // {
1015 //
1016 // *((path_meta*)this) = path_meta();
1017 //
1018 // m_epath = file_path_get_type(str);
1019 //
1020 // string ::operator = (file_path_normalize(str, m_epath));
1021 //
1022 // return *this;
1023 //
1024 // }
1025
1026
1027 //inline path path::operator + (const path& path) const
1028 //{
1029
1030 // return ::file::path((const string&)*this + string((const string&)path), m_epath);
1031
1032 //}
1033
1034
1035 //inline path path::operator + (const ::ansi_string& str) const
1036 //{
1037
1038 // return ::file::path((const string&)*this + (m_iDir > 0 ? separator_sz() : "") + string((const string&)str), m_epath);
1039
1040 //}
1041
1042
1043 //inline path path::operator + (const ::scoped_string & scopedstr) const
1044 //{
1045
1046 // return operator + (string(scopedstr));
1047
1048 //}
1049
1050
1051
1052 // inline path& path::operator = (const ::scoped_string & scopedstr)
1053 // {
1054 //
1055 // return operator = (string(scopedstr));
1056 //
1057 // }
1058
1059
1060 //inline path& path::operator += (const ::scoped_string & scopedstr)
1061 //{
1062
1063 // return operator += (string(scopedstr));
1064
1065 //}
1066
1067 // inline path& path::operator = (const wstring& wstr)
1068 // {
1069 //
1070 // return operator = (string(wstr));
1071 //
1072 // }
1073
1074 //inline path& path::operator += (const wstring& wstr) { return operator += (string(wstr)); }
1075
1077 //inline path& path::operator += (const ::wide_character* psz) { return operator += (wstring(scopedstr)); }
1078
1079 //void path::to_string(string & str) const
1080 //{
1081 //
1082 // str = *this;
1083
1084 //}
1085
1086// inline path path::operator * (const path & path) const
1087// {
1088//
1089// return sibling(path);
1090//
1091// }
1092
1093// inline path path::operator * (const ::ansi_string & str) const { return operator * (::file::path(str)); }
1094//
1095// inline path & path::operator *= (const path & path)
1096// {
1097//
1098// if (this != &path)
1099// {
1100//
1101// *this = sibling(path);
1102//
1103// }
1104//
1105// return *this;
1106//
1107// }
1108//
1109// inline path & path::operator *= (const ::ansi_string & str) { return operator *= (::file::path(str)); }
1110
1111
1112 inline ::const_ansi_range path::title() const
1113 {
1114
1115 auto rangeName = this->name();
1116
1117 auto end = rangeName.find('.');
1118
1119 if (::is_null(end))
1120 {
1121
1122 return rangeName;
1123
1124 }
1125
1126 return rangeName(0, end);
1127
1128 }
1129
1130
1131 inline ::const_ansi_range path::name() const
1132 {
1133
1134 auto p = rear_find_first_character_in("\\/");
1135
1136 if (::is_null(p))
1137 {
1138
1139 return *this;
1140
1141 }
1142
1143 return { p + 1, this->end() };
1144
1145 }
1146
1147
1148 inline path::const_iterator path::find_name() const
1149 {
1150
1151 return maximum(this->begin(), rear_find('/') + 1);
1152
1153 }
1154
1155
1156 inline ::const_ansi_range path::find_final_extension() const
1157 {
1158
1159 auto rangeName = this->name();
1160
1161 auto last_dot = rangeName.rear_find('.');
1162
1163 if (!last_dot)
1164 {
1165
1166 return {};
1167
1168 }
1169
1170 return { last_dot + 1, this->end() };
1171
1172 }
1173
1174
1175 inline ::const_ansi_range path::find_all_extensions() const
1176 {
1177
1178 auto rangeName = this->name();
1179
1180 auto name_first_dot = rangeName.find('.');
1181
1182 if (!name_first_dot)
1183 {
1184
1185 return {};
1186
1187 }
1188
1189 return { name_first_dot + 1, this->end() };
1190 }
1191
1192
1193 inline bool path::is_relative()
1194 {
1195
1196 return file_path_is_relative(*this) != false;
1197
1198 }
1199
1200
1201 //inline path path::relative() const
1202 //{
1203
1204 // return this->substr(maximum(0, m_iBasePathLength));
1205
1206 //}
1207
1208
1209 inline path path::parent() const
1210 {
1211
1212 return folder();
1213
1214 }
1215
1216
1217 inline path path::ascendant(::i32 i) const
1218 {
1219
1220 return folder(i);
1221
1222 }
1223
1224
1225 inline path& path::operator -= (::i32 i)
1226 {
1227
1228 return ascend(i);
1229
1230 }
1231
1232
1233 inline bool path::is_empty() const
1234 {
1235
1236 return ::ansi_string::is_empty();
1237
1238 }
1239
1240
1241 inline bool path::has_character() const
1242 {
1243
1244 return !is_empty();
1245
1246 }
1247
1248
1249 inline bool path::operator == (const ::scoped_string& scopedstr) const
1250 {
1251
1252 return operator == (path(scopedstr));
1253
1254 }
1255
1256
1257 inline bool path::operator != (const ::ansi_string& str) const
1258 {
1259
1260 return operator != (path(str));
1261
1262 }
1263
1264
1265 // inline path path::operator / (const ::scoped_string & scopedstr) const
1266 // {
1267 //
1268 // return ::transfer(slashed_path(scopedstr));
1269 //
1270 // }
1271
1272
1273 inline ::file::path& path::patch_base_path(const ::file::path& pathBase)
1274 {
1275
1276 auto iBasePathLength = m_iBasePathLength;
1277
1278 if (iBasePathLength < 0)
1279 {
1280
1281 iBasePathLength = 0;
1282
1283 }
1284
1285 auto pszRelative = c_str() + iBasePathLength;
1286
1287 *this = pathBase / pszRelative;
1288
1289 m_iBasePathLength = pathBase.length() + 1;
1290
1291 return *this;
1292
1293 }
1294
1295
1296 inline bool path::operator != (const path& path) const
1297 {
1298
1299 return !operator==(path);
1300
1301 }
1302
1303
1304
1305
1306} // namespace file
1307
1308
1309//inline ::file::path operator +(const ::file::path & path1, const ::file::path & path2)
1310//{
1311//
1312// return ::transfer(::file::path(((const::string &)path1) + ((const ::string&)path2)));
1313//
1314//}
1315
1316
1317// For MSVC, but not for GCC?
1318//inline ::file::path operator +(const ::file::path & path, const ::scoped_string & scopedstr)
1319//{
1320//
1321// return ((const::string &)path) + str;
1322//}
1323
1324
1325//inline ::file::path operator + (const ::file::path & path, const ::scoped_string & scopedstr)
1326//{
1327//
1328// return ((const::string &)path) + scopedstr;
1329//}
1330
1331
1332//inline ::file::path operator + (const ::file::path & path, const ::atom & atom)
1333//{
1334//
1335// return ((const::string &)path) + atom;
1336//
1337//}
1338//
1339//
1340//inline ::file::path operator +(const ::file::path & path, const ::file::path::RANGE & range)
1341//{
1342//
1343// return ((const::string &)path) + ::string(range);
1344//
1345//}
1346
1347
1348
1349//template < character_count m_sizeMaximumLength >
1350//inline ::file::path operator +(const ::file::path & path, const ::inline_string < ::i8, m_sizeMaximumLength > & inlinestring)
1351//{
1352//
1353// return ((const ::string &)path) + ::string(inlinestring);
1354//
1355//}
1356//
1357//
1358//template < character_count c >
1359//inline ::file::path operator +(const ::file::path & path, const ::ansi_character(&cha)[c])
1360//{
1361//
1362// return ((const ::string &)path) + ::string(cha);
1363//
1364//}
1365//
1366//
1367//inline ::file::path operator +(const ::scoped_string & scopedstr, const ::file::path & path)
1368//{
1369//
1370// return str + ((const::string &)path);
1371//}
1372//
1373//
1374//inline ::file::path operator +(const ::const_ansi_range & range, const ::file::path & path)
1375//{
1376//
1377// return ::string(range) + ((const::string &)path);
1378//
1379//}
1380//
1381//
1382//
1383//template < ::collection::count c >
1384//inline ::file::path operator +(const ::i8(&sz)[c], const ::file::path & path)
1385//{
1386//
1387// return ::string(sz) + ((const::string &)path);
1388//
1389//}
1390
1391
1392//namespace file
1393//{
1394//
1395// // inline path::path(const ::payload & payload,e_path epath): path(payload.get_file_path(),epath){}
1396// // inline path::path(const property & property,e_path epath, e_type etype): path(property.get_file_path(),epath, iDir) {}
1397// //inline path & path::operator = (const ::payload & payload) { return operator = (payload.get_string()); }
1398// //inline path & path::operator += (const ::payload & payload) { return operator += (payload.get_string()); }
1399// //inline path & path::operator = (const property & property) { return operator = ((const ::payload &)property); }
1400// //inline path & path::operator += (const property & property) { return operator += ((const ::payload &) property); }
1401// //inline path path::operator + (const ::payload & payload) const { return operator + (payload.get_string()); }
1402// //inline path path::operator + (const property & property) const { return operator + (property.get_string()); }
1403// //inline path path::operator + (const atom & atom) const { return operator + (atom.str()); }
1404// //inline path path::operator / (const ::payload & payload) const { return operator /(::file::path(payload)); }
1405// //inline path path::operator / (const property & property) const { return operator /(::file::path(property)); }
1406// //inline path path::operator * (const property & property) const { return operator *(::file::path(property)); }
1407// //inline path & path::operator *= (const property & property) { return operator *=(::file::path(property)); }
1408// inline path path::folder() const { return { ::file_path_folder(*this), m_epath }; }
1409// inline path path::sibling(const path & path) const { return { ::file_path_folder(*this) + ::string(this->separator()) + ::string(::sz::trim_left_path_sep(path)), m_epath }; }
1410// inline path path::sibling(const ::scoped_string & scopedstr) const { return { ::file_path_folder(*this) + ::string(this->separator()) + ::string(::sz::trim_left_path_sep(str)), m_epath }; }
1411// //inline path path::sibling(const ::scoped_string & scopedstr) const { return { ::file_path_folder(*this) + sep() + ::sz::trim_left_path_sep(scopedstr), m_epath }; }
1412// //inline string path::extension() const { return &m_pdata[find_skip_or_length('.', rear_find(sep()) + 1)]; }
1413// inline string path::final_extension() const { return file_path_final_extension(operator const_char_pointer ()); }
1414// //inline patha path::ascendants_path() const { patha patha; return ascendants_path(patha); }
1415// //inline string_array_base path::ascendants_name() const { string_array_base patha; return ascendants_name(patha); }
1416// // inline path path::folder() const { return ::file_path_folder(*this); }
1417// //inline bool path::operator == (const ::payload & payload) const { return operator == (string(payload)); }
1418// //inline bool path::operator != (const ::payload & payload) const { return operator != (string(payload)); }
1419//
1420//} // namespace file
1421//
1422
1423
1424
1425
1426
1427//namespace url
1428//{
1429//
1430//
1431// inline url::url(const ::file::path& path) :
1432// url((const ::scoped_string &) (const ::string&)path)
1433// {
1434//
1435//
1436// }
1437//
1438//
1439//
1440//} // namespace url
1441
1442
1443
1444
1445namespace file
1446{
1447
1448
1449 inline ::url::url path::as_url() const
1450 {
1451
1452 if (::url::is(*this))
1453 {
1454
1455 return (const ::scoped_string&)*this;
1456
1457 }
1458 else
1459 {
1460
1461 ::string str("file://");
1462
1463 str += *this;
1464
1465 return (const ::scoped_string&)str;
1466
1467 }
1468
1469 }
1470
1471
1472 inline const_ansi_range path::_get_count_parts_from_beginning(::collection::count cPathPartCountToConsume) const
1473 {
1474
1475 return ::string::_get_count_parts_from_beginning(cPathPartCountToConsume, '/');
1476
1477 }
1478
1479
1480 inline const_ansi_range path::get_count_parts_from_beginning(::collection::count cPathPartCountToConsume) const
1481 {
1482
1483 return ::string::_get_count_parts_from_beginning(cPathPartCountToConsume, '/');
1484
1485 }
1486
1487 // bool path::has_count_parts_from_beginning_eat(::collection::count cPathPartCountToConsume)
1488 //{
1489 //
1490 // auto range = this->get_count_parts_from_beginning(cPathPartCountToConsume);
1491 //
1492 // if(::is_null(range.m_begin))
1493 // {
1494 //
1495 // return false;
1496 //
1497 // }
1498 //
1499 // return this->_assign(range.m_begin, range.size());
1500 //
1501 //}
1502
1503
1504} // namespace file
1505
1506
1507
1508
1509
1510template < prototype_character_range RANGE1, prototype_character_range RANGE2 >
1511::file::path operator / (const RANGE1& range1, const RANGE2& range2)
1512{
1513
1514 return ::transfer(::file::path(range1).slashed_path(range2));
1515
1516}
1517
1518
1519
1520template < character_pointer CHARACTER_POINTER, prototype_character_range RANGE >
1521::file::path operator / (CHARACTER_POINTER p, const RANGE& range)
1522{
1523
1524 return ::transfer(::file::path(p) / ::string(range));
1525
1526}
1527
1528
1529
1530
1531template < prototype_character_range RANGE, character_count n >
1532::file::path operator / (const typename RANGE::CHARACTER(&sz)[n], const RANGE& range)
1533{
1534
1535 return ::transfer(::file::path(sz) / ::string(range));
1536
1537}
1538
1539
1540
1541//template < prototype_character ITERATOR_TYPE2, ::i32 t_size, prototype_character_range RANGE >
1542//::file::path operator / (const const_string_range_static_array <ITERATOR_TYPE2, t_size >& a, const RANGE& range)
1543//{
1544//
1545// return ::transfer(::file::path(a) / ::string(range));
1546//
1547//}
1548
1549
1550template < prototype_character_range RANGE, character_pointer CHARACTER_POINTER >
1551::file::path operator / (const RANGE& range, CHARACTER_POINTER p)
1552{
1553
1554 if constexpr (::std::is_same<RANGE, ::file::path>::value)
1555 {
1556
1557 return ::transfer(range.slashed_path(p));
1558
1559 }
1560 else
1561 {
1562
1563 ::file::path path(range);
1564
1565 return ::transfer(path.slashed_path(p));
1566
1567 }
1568
1569}
1570
1571
1572//template < prototype_character_range RANGE, typename ITERATOR_TYPE2, ::i32 t_size >
1573//::file::path operator / (const RANGE& range, const const_string_range_static_array <ITERATOR_TYPE2, t_size >& a)
1574//{
1575//
1576// return ::transfer(::file::path(range) / ::file::path(a));
1577//
1578//}
1579//
1580
1581//template < typename ITERATOR_TYPE2, character_count n, ::i32 t_size >
1582//::file::path operator / (const ::non_pointer < non_const <ITERATOR_TYPE2>>(&sz)[n], const const_string_range_static_array <ITERATOR_TYPE2, t_size >& a)
1583//{
1584//
1585// return ::transfer(::file::path(sz) / ::string(a));
1586//
1587//}
1588
1589//
1590//template<prototype_character CHARACTER>
1591//inline ::file::path operator/(const ::character_range<const CHARACTER *> &range, const ::atom &atom)
1592//{
1593//
1594// return ::file::path(range) / ::file::path(atom.as_string());
1595//}
1596//
1597//
Definition path.h:52
const_iterator find_name() const
return index pointing to beginning of name
Definition _impl_path.h:1148
::const_ansi_range find_final_extension() const
Definition _impl_path.h:1156
::const_ansi_range find_all_extensions() const
Definition _impl_path.h:1175
Definition folder.h:13
Definition range.h:223
Definition filesystem.h:16