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"
47 inline path_meta::path_meta(enum_path epath, ::i64 iSize, e_type etype, ::i64 iName, character_count iBasePathLength, const ::file::e_flag & eflag)
53 m_iName = (character_count)iName;
54 m_iBasePathLength = iBasePathLength;
112 inline path_meta::~path_meta()
267 inline path::~path() noexcept
442 inline path path::folder(::i32 i)
const
445 ::file::path path(*
this);
450 path = path.folder();
461 inline path& path::ascend()
464 return *
this = parent();
469 inline path& path::ascend(::i32 i)
516 inline path& path::operator += (const ::scoped_string& scopedstr)
519 auto pathThis = *
this;
521 ::string::operator = (file_path_normalize(((const ::string&)pathThis) + scopedstr, this->m_epath));
660 inline void path::set_all_extensions(const ::scoped_string& scopedstrExtension)
663 string strExtension(scopedstrExtension);
665 strExtension.case_insensitive_begins_eat(
".");
669 if (range.begin() >= this->begin() + 1)
672 this->operator = ((*
this)(0, range.begin()) + strExtension);
678 this->operator += (
"." + strExtension);
685 inline void path::set_final_extension(const ::scoped_string& scopedstrExtension)
688 string strExtension(scopedstrExtension);
690 strExtension.case_insensitive_begins_eat(
".");
694 if (range.begin() >= this->begin() + 1)
697 this->operator = ((*
this)(0, range.begin()) + strExtension);
703 this->operator += (
"." + strExtension);
710 inline void path::set_extension_if_no_extension(const ::scoped_string& scopedstrExtension)
713 if (this->final_extension().is_empty())
716 auto p = scopedstrExtension.skip(
'.');
718 if (::has_character(p))
721 this->operator = (((::ansi_string&)*
this) +
"." + scopedstrExtension(p));
730 inline void path::defer_set_extension(const ::string_array_base& straPreserveExtensions)
733 defer_set_extension(straPreserveExtensions, {});
739 inline void path::defer_set_extension(const ::string_array_base& straPreserveExtensions, const ::string_array_base& straRelatedExtensions)
742 if (straPreserveExtensions.is_empty())
745 throw ::exception(error_bad_argument);
753 ::string strRearSuffix;
760 for (
auto& strExtension : straPreserveExtensions)
763 if (strRearSuffix.has_character())
766 bErased = str.case_insensitive_ends_eat(
"." + strExtension);
772 bErased = str.ends_erase_get_erased(strRearSuffix,
"." + strExtension);
774 strRearSuffix.begins_eat(
".");
790 for (
auto& strRelatedExtension : straRelatedExtensions)
793 bErased = str.case_insensitive_ends_eat(
"." + strRelatedExtension);
808 if (strRearSuffix.has_character())
811 str +=
"." + strRearSuffix;
817 str +=
"." + straPreserveExtensions.first();
821 this->operator =(str);
826 inline ::file::path path::with_all_extensions(const ::scoped_string& scopedstrExtension)
const
829 ::file::path path(*
this);
831 path.set_all_extensions(scopedstrExtension);
833 return ::transfer(path);
838 inline ::file::path path::with_final_extension(const ::scoped_string& scopedstrExtension)
const
841 ::file::path path(*
this);
843 path.set_final_extension(scopedstrExtension);
845 return ::transfer(path);
850 inline ::file::path path::with_extension_if_no_extension(const ::scoped_string& scopedstrExtension)
const
853 ::file::path path(*
this);
855 path.set_extension_if_no_extension(scopedstrExtension);
857 return ::transfer(path);
862 inline ::file::path path::with_deferred_extension(const ::string_array_base& straPreserveExtensions)
const
865 return with_deferred_extension(straPreserveExtensions, {});
870 inline ::file::path path::with_deferred_extension(const ::file::file_dialog* pfiledialog)
const
873 return with_deferred_extension(
874 pfiledialog->m_filedialogfilter[0].get_preserve_extensions(),
875 pfiledialog->m_filedialogfilter.get_all_related_extensions());
880 inline ::file::path path::with_deferred_extension(const ::string_array_base& straPreserveExtensions, const ::string_array_base& straRelatedExtensions)
const
883 ::file::path path(*
this);
885 path.defer_set_extension(straPreserveExtensions, straRelatedExtensions);
887 return ::transfer(path);
892 inline ::windows_path path::windows_path()
const
900 inline void path::set_type(enum_path epath)
903 if (epath != m_epath)
908 ::ansi_string ::operator = (file_path_normalize(*
this, m_epath));
915 inline path& path::set_file_path(const ::scoped_string& scopedstrFile)
918 operator = (scopedstrFile);
927 inline path& path::set_folder_path(const ::scoped_string& scopedstrFolder)
930 operator = (scopedstrFolder);
939 inline path& path::set_file_path()
942 m_etype = ((m_etype | e_type_file2) & ~e_type_folder2);
949 inline path& path::set_folder_path()
952 m_etype = ((m_etype | e_type_folder2) & ~e_type_file2);
959 inline path& path::set_existent_file()
971 inline path& path::set_existent()
974 m_etype = ((m_etype | e_type_exists) & ~e_type_doesnt_exist);
981 inline path& path::set_existent_folder()
993 inline path& path::operator = (const ::file::path&
path)
999 string::operator = ((
const string&)path);
1000 *((path_meta*)
this) = (
const path_meta&)path;
1112 inline ::const_ansi_range path::title()
const
1115 auto rangeName = this->name();
1117 auto end = rangeName.find(
'.');
1126 return rangeName(0, end);
1131 inline ::const_ansi_range path::name()
const
1134 auto p = rear_find_first_character_in(
"\\/");
1143 return { p + 1, this->end() };
1151 return maximum(this->begin(), rear_find(
'/') + 1);
1159 auto rangeName = this->name();
1161 auto last_dot = rangeName.rear_find(
'.');
1170 return { last_dot + 1, this->end() };
1178 auto rangeName = this->name();
1180 auto name_first_dot = rangeName.find(
'.');
1182 if (!name_first_dot)
1189 return { name_first_dot + 1, this->end() };
1193 inline bool path::is_relative()
1196 return file_path_is_relative(*
this) !=
false;
1209 inline path path::parent()
const
1217 inline path path::ascendant(::i32 i)
const
1225 inline path& path::operator -= (::i32 i)
1233 inline bool path::is_empty()
const
1236 return ::ansi_string::is_empty();
1241 inline bool path::has_character()
const
1249 inline bool path::operator == (const ::scoped_string& scopedstr)
const
1252 return operator == (path(scopedstr));
1257 inline bool path::operator != (const ::ansi_string& str)
const
1260 return operator != (path(str));
1273 inline ::file::path& path::patch_base_path(const ::file::path& pathBase)
1276 auto iBasePathLength = m_iBasePathLength;
1278 if (iBasePathLength < 0)
1281 iBasePathLength = 0;
1285 auto pszRelative = c_str() + iBasePathLength;
1287 *
this = pathBase / pszRelative;
1289 m_iBasePathLength = pathBase.length() + 1;
1296 inline bool path::operator != (
const path&
path)
const
1299 return !operator==(path);
1449 inline ::url::url path::as_url()
const
1452 if (::url::is(*
this))
1455 return (const ::scoped_string&)*
this;
1461 ::string str(
"file://");
1465 return (const ::scoped_string&)str;
1472 inline const_ansi_range path::_get_count_parts_from_beginning(::collection::count cPathPartCountToConsume)
const
1475 return ::string::_get_count_parts_from_beginning(cPathPartCountToConsume,
'/');
1480 inline const_ansi_range path::get_count_parts_from_beginning(::collection::count cPathPartCountToConsume)
const
1483 return ::string::_get_count_parts_from_beginning(cPathPartCountToConsume,
'/');
1510template < prototype_
character_range RANGE1, prototype_
character_range RANGE2 >
1511::file::path operator / (
const RANGE1& range1,
const RANGE2& range2)
1514 return ::transfer(
::file::path(range1).slashed_path(range2));
1520template <
character_po
inter CHARACTER_POINTER, prototype_
character_range RANGE >
1531template < prototype_
character_range RANGE,
character_count n >
1532::file::path operator / (
const typename RANGE::CHARACTER(&sz)[n],
const RANGE&
range)
1550template < prototype_
character_range RANGE,
character_po
inter CHARACTER_POINTER >
1554 if constexpr (::std::is_same<RANGE, ::file::path>::value)
1557 return ::transfer(
range.slashed_path(p));
1565 return ::transfer(path.slashed_path(p));
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 filesystem.h:16