reference.html 205 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337
  1. <html>
  2. <!-- &copy; Copyright Beman Dawes, 2002, 2006, 2007, 2009, 2010, 2011 -->
  3. <!-- Distributed under the Boost Software License, Version 1.0. -->
  4. <!-- See http://www.boost.org/LICENSE_1_0.txt -->
  5. <!-- generate-section-numbers=false -->
  6. <head>
  7. <meta http-equiv="Content-Language" content="en-us">
  8. <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
  9. <meta name="ProgId" content="FrontPage.Editor.Document">
  10. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  11. <link href="styles.css" rel="stylesheet">
  12. <title>Filesystem Reference</title>
  13. </head>
  14. <body>
  15. <table border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111">
  16. <tr>
  17. <td width="277">
  18. <p>
  19. <a href="../../../index.htm">
  20. <img src="../../../boost.png" alt="boost.png (6897 bytes)" align="middle" width="300" height="86" border="0"></a></td>
  21. <td align="middle">
  22. <font size="7">Filesystem Library<br>
  23. </font>
  24. <font size="6">Version 3</font></td>
  25. </tr>
  26. </table>
  27. <table border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse"
  28. bordercolor="#111111" bgcolor="#D7EEFF" width="100%">
  29. <tr>
  30. <td><a href="index.htm">Home</a> &nbsp;&nbsp;
  31. <a href="tutorial.html">Tutorial</a> &nbsp;&nbsp;
  32. <a href="reference.html">Reference</a> &nbsp;&nbsp;
  33. <a href="faq.htm">FAQ</a> &nbsp;&nbsp;
  34. <a href="release_history.html">Releases</a> &nbsp;&nbsp;
  35. <a href="portability_guide.htm">Portability</a> &nbsp;&nbsp;
  36. <a href="v3.html">V3 Intro</a> &nbsp;&nbsp;
  37. <a href="v3_design.html">V3 Design</a> &nbsp;&nbsp;
  38. <a href="deprecated.html">Deprecated</a> &nbsp;&nbsp;
  39. <a href="issue_reporting.html">Bug Reports </a>&nbsp;&nbsp;
  40. </td>
  41. </table>
  42. <h1>Reference Documentation</h1>
  43. <h2><a name="TOC">Table of Contents</a></h2>
  44. <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
  45. <tr>
  46. <td width="33%" valign="top">
  47. <p><a href="#Introduction">Introduction</a><br>
  48. <a href="#Definitions">Definitions</a><br>
  49. <a href="#Conformance">Conformance</a><br>
  50. <a href="#Header-filesystem-synopsis">
  51. Header <code>&lt;boost/filesystem.hpp&gt;</code> synopsis</a><br>
  52. <a href="#Error-reporting">Error reporting</a><br>
  53. <a href="#class-path">Class <code>path</code></a><br>
  54. &nbsp;&nbsp;&nbsp; <a href="#path-Conversions"><code>path</code> conversions</a><br>
  55. &nbsp;&nbsp;&nbsp; <a href="#path-Conversions-to-native-format"><code>path</code>
  56. conversions to native format</a><br>
  57. &nbsp;&nbsp;&nbsp; <a href="#path-Conversions-to-generic-format"><code>path</code>
  58. conversions to generic format</a><br>
  59. &nbsp;&nbsp;&nbsp; <a href="#path-Encoding-conversions"><code>path</code>
  60. encoding conversions</a><br>
  61. &nbsp;&nbsp;&nbsp; <a href="#path-Requirements"><code>path</code> requirements</a><br>
  62. &nbsp;&nbsp;&nbsp; <a href="#path-constructors"><code>path</code> constructors</a><br>
  63. &nbsp;&nbsp;&nbsp; <a href="#path-assignments"><code>path</code> assignments</a><br>
  64. &nbsp;&nbsp;&nbsp;&nbsp;<a href="#path-appends"><code>path</code> appends</a><br>
  65. &nbsp;&nbsp; &nbsp;<a href="#path-concatenation"><code>path</code> concatenation</a><br>
  66. &nbsp;&nbsp;&nbsp;&nbsp;<a href="#path-modifiers"><code>path</code> modifiers</a><br>
  67. &nbsp;&nbsp;&nbsp;&nbsp;<a href="#path-native-format-observers"><code>path</code> native
  68. format observers</a><br>
  69. &nbsp;&nbsp;&nbsp;&nbsp;<a href="#path-generic-format-observers"><code>path</code> generic
  70. format observers</a><br>
  71. &nbsp;&nbsp;&nbsp; <a href="#path-compare"><code>path</code> compare</a><br>
  72. &nbsp;&nbsp;&nbsp; <a href="#path-decomposition"><code>path</code> decomposition</a><br>
  73. &nbsp;&nbsp;&nbsp; <a href="#path-query"><code>path</code> query</a><br>
  74. &nbsp;&nbsp;&nbsp;&nbsp;<a href="#path-iterators"><code>path</code> iterators</a><br>
  75. &nbsp;&nbsp;&nbsp;&nbsp;<a href="#path-deprecated-functions"><code>path</code> deprecated functions</a><br>
  76. &nbsp;&nbsp;&nbsp;&nbsp;<a href="#path-non-member-functions"><code>path</code> non-member functions</a><br>
  77. &nbsp;&nbsp;&nbsp;&nbsp;<a href="#path-inserter-extractor"><code>path</code> inserters and extractors</a><br>
  78. &nbsp;<a href="#Class-filesystem_error">Class <code>filesystem_error</code></a><br>
  79. &nbsp;&nbsp;&nbsp; <a href="#filesystem_error-members"><code>filesystem_error</code>
  80. constructors</a><br>
  81. &nbsp;&nbsp;&nbsp; <a href="#filesystem_error-path1"><code>filesystem_error</code> path1</a><br>
  82. &nbsp;&nbsp;&nbsp; <a href="#filesystem_error-path2"><code>filesystem_error</code> path2</a><br>
  83. &nbsp;&nbsp;&nbsp; <a href="#filesystem_error-what"><code>filesystem_error</code> what</a></td>
  84. <td width="33%" valign="top">
  85. <p>
  86. <a href="#Enum-file_type">Enum <code>file_type</code></a><br>
  87. <a href="#Enum-perms">Enum <code>perms</code></a><br>
  88. <a href="#file_status">Class
  89. <code>file_status</code></a><br>
  90. &nbsp;&nbsp;&nbsp;
  91. <a href="#file_status">
  92. <code>file_status</code></a><a href="#file_status-constructors"> constructors</a><br>
  93. &nbsp;&nbsp;&nbsp;&nbsp;<code><a href="#file_status-modifiers">file_status-modifiers</a></code><a href="#directory_entry-observers"> observers</a><br>
  94. &nbsp;&nbsp;&nbsp;&nbsp;<code><a href="#file_status-observers">file_status-observers</a></code><a href="#directory_entry-modifiers"> modifiers</a><br>
  95. <a href="#Class-directory_entry">Class <code>directory_entry</code></a><br>
  96. &nbsp;&nbsp;&nbsp;
  97. <a href="#directory_entry-constructors"><code>directory_entry</code> constructors</a><br>
  98. &nbsp;&nbsp;&nbsp;&nbsp;<a href="#directory_entry-observers"><code>directory_entry</code> observers</a><br>
  99. &nbsp;&nbsp;&nbsp;&nbsp;<a href="#directory_entry-modifiers"><code>directory_entry</code> modifiers</a><br>
  100. <a href="#Class-directory_iterator">Class <code>directory_iterator</code></a><br>
  101. &nbsp;&nbsp;&nbsp; <a href="#directory_iterator-members"><code>directory_iterator</code>
  102. members</a><br>
  103. <a href="#Class-recursive_directory_iterator">Class <code>recursive_directory_iterator</code></a><br>
  104. <a href="#Operational-functions">
  105. Operational functions</a><br>
  106. <code>&nbsp;&nbsp;&nbsp;&nbsp; <a href="#absolute">absolute</a><br>
  107. &nbsp;&nbsp;&nbsp;&nbsp; <a href="#canonical">canonical</a><br>
  108. &nbsp;&nbsp;&nbsp;&nbsp; <a href="#copy">copy</a><br>
  109. &nbsp;&nbsp;&nbsp;&nbsp; <a href="#copy_directory">copy_directory</a><br>
  110. &nbsp;&nbsp;&nbsp;&nbsp; <a href="#copy_file">copy_file</a><br>
  111. &nbsp;&nbsp;&nbsp;&nbsp; <a href="#copy_symlink">copy_symlink</a><br>
  112. &nbsp;&nbsp;&nbsp;&nbsp; <a href="#create_directories">create_directories</a><br>
  113. &nbsp;&nbsp;&nbsp;&nbsp; <a href="#create_directory">create_directory</a><br>
  114. &nbsp;&nbsp;&nbsp;&nbsp; <a href="#create_hard_link">create_hard_link</a><br>
  115. &nbsp;&nbsp;&nbsp;&nbsp; <a href="#create_symlink">create_symlink</a><br>
  116. &nbsp;&nbsp;&nbsp;&nbsp; <a href="#current_path">current_path</a><br>
  117. &nbsp;&nbsp;&nbsp;&nbsp; <a href="#exists">exists</a><br>
  118. &nbsp;&nbsp;&nbsp;&nbsp; <a href="#equivalent">equivalent</a><br>
  119. &nbsp;&nbsp;&nbsp;&nbsp; <a href="#file_size">file_size</a><br>
  120. &nbsp;&nbsp;&nbsp;&nbsp; <a href="#hard_link_count">hard_link_count</a><br>
  121. &nbsp;&nbsp;&nbsp;&nbsp; <a href="#initial_path">initial_path</a><br>
  122. &nbsp;&nbsp;&nbsp;&nbsp; i<a href="#is_directory">s_directory</a><br>
  123. &nbsp;&nbsp;&nbsp;&nbsp; <a href="#is_empty">is_empty</a></code></td>
  124. <td width="34%" valign="top">
  125. <p>
  126. <code>&nbsp;&nbsp;&nbsp;&nbsp; <a href="#is_other">is_other</a><br>
  127. &nbsp;&nbsp;&nbsp;&nbsp; <a href="#is_regular_file">is_regular_file</a><br>
  128. &nbsp;&nbsp;&nbsp;&nbsp; <a href="#is_symlink">is_symlink</a><br>
  129. &nbsp;&nbsp;&nbsp;&nbsp; <a href="#last_write_time">last_write_time</a><br>
  130. &nbsp;&nbsp;&nbsp;&nbsp; <a href="#permissions">permissions</a><br>
  131. &nbsp;&nbsp;&nbsp;&nbsp; <a href="#read_symlink">read_symlink</a><br>
  132. &nbsp;&nbsp;&nbsp;&nbsp; <a href="#op-relative">relative</a><br>
  133. &nbsp;&nbsp;&nbsp;&nbsp; <a href="#remove">remove</a><br>
  134. &nbsp;&nbsp;&nbsp;&nbsp; <a href="#remove_all">remove_all</a><br>
  135. &nbsp;&nbsp;&nbsp;&nbsp; <a href="#rename">rename</a><br>
  136. &nbsp;&nbsp;&nbsp;&nbsp; <a href="#resize_file">resize_file</a><br>
  137. &nbsp;&nbsp;&nbsp;&nbsp; <a href="#space">space</a><br>
  138. &nbsp;&nbsp;&nbsp;&nbsp; <a href="#status">status</a><br>
  139. &nbsp;&nbsp;&nbsp;&nbsp; <a href="#status_known">status_known</a><br>
  140. &nbsp;&nbsp;&nbsp;&nbsp; <a href="#symlink_status">symlink_status</a><br>
  141. &nbsp;&nbsp;&nbsp;&nbsp; <a href="#system_complete">system_complete</a><br>
  142. &nbsp;&nbsp;&nbsp;&nbsp; <a href="#temp_directory_path">temp_directory_path</a><br>
  143. &nbsp;&nbsp;&nbsp;&nbsp; <a href="#unique_path">unique_path</a><br>
  144. &nbsp;&nbsp;&nbsp;&nbsp; <a href="#weakly_canonical">weakly_canonical</a><br></code>
  145. <a href="#File-streams">File streams</a><br>
  146. <a href="#path-decomposition-table">Path decomposition table</a><br>
  147. <a href="#long-path-warning">Warning: Long paths on Windows and the
  148. extended-length <b>\\?\ </b>prefix</a><br>
  149. <a href="#Acknowledgements">Acknowledgements</a><br>
  150. <a href="#References">References</a><br>
  151. &nbsp;</td>
  152. </tr>
  153. </table>
  154. <h2><a name="Introduction">Introduction</a></h2>
  155. <p>This reference documentation describes components that C++ programs may use
  156. to perform operations involving file systems, including paths, regular files,
  157. and directories.</p>
  158. <blockquote>
  159. <table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse"
  160. bordercolor="#111111" bgcolor="#D7EEFF" width="90%">
  161. <tr>
  162. <td width="100%" align="center" colspan="2">
  163. <p align="center"><b>C++11 Support</b><p align="left">This reference
  164. documentation is written as if all compilers supported C++11. Where
  165. possible, the implementation falls back to C++03 if a C++11 feature is not
  166. available.</td>
  167. </tr>
  168. <tr>
  169. <td width="35%" align="center">
  170. <p>
  171. <b>C++11 Feature</b></td>
  172. <td width="65%" align="center">
  173. <p>
  174. <b>Action if not supported by compiler</b></td>
  175. </tr>
  176. <tr>
  177. <td width="35%" align="left">
  178. <p>
  179. <code>noexcept</code></td>
  180. <td width="65%" align="left">
  181. <p>Keyword omitted.</td>
  182. </tr>
  183. <tr>
  184. <td width="35%" align="left">
  185. <p>
  186. <code>constexpr</code></td>
  187. <td width="65%" align="left">
  188. <p>Keyword omitted.</td>
  189. </tr>
  190. <tr>
  191. <td width="35%" align="left">
  192. <p>R-value references</td>
  193. <td width="65%" align="left">
  194. <p>Function signature omitted.</td>
  195. </tr>
  196. <tr>
  197. <td width="35%" align="left">
  198. <p>New character types</td>
  199. <td width="65%" align="left">
  200. <p>The <code>boost::filesystem</code> interface doesn't use the
  201. new types directly. It does use <code>u16string</code> and <code>u32string</code>
  202. in namespace <code>boost</code>. These are typedefs to <code>std::u16string</code>
  203. and <code>std::u32string</code> for C++11, or to <code>
  204. std::basic_string&lt;boost::u16_t&gt;</code> and <code>
  205. std::basic_string&lt;boost::u32_t&gt;</code> for C++03.</td>
  206. </tr>
  207. <tr>
  208. <td width="35%" align="left">
  209. <p>Defaulted and deleted functions</td>
  210. <td width="65%" align="left">
  211. <p>Workaround replacement functions provided.</td>
  212. </tr>
  213. <tr>
  214. <td width="35%" align="left">
  215. <p>Initializer lists</td>
  216. <td width="65%" align="left">
  217. <p>Not currently used.</td>
  218. </tr>
  219. <tr>
  220. <td width="35%" align="left">
  221. <p>Variadic templates</td>
  222. <td width="65%" align="left">
  223. <p>Not currently used.</td>
  224. </tr>
  225. <tr>
  226. <td width="35%" align="left">
  227. <p>Range-based for statements</td>
  228. <td width="65%" align="left">
  229. <p>Supporting functions always provided; they do no harm even for C++03
  230. compilers.</td>
  231. </tr>
  232. </table>
  233. </blockquote>
  234. <h2><a name="Conformance">Conformance</a> [fs.conformance]</h2>
  235. <h3>ISO/IEC 9945 conformance [fs.conform.9945]</h3>
  236. <p>Some behavior in this reference documentation is specified by reference to ISO/IEC 9945. How such behavior is actually implemented is unspecified.</p>
  237. <blockquote>
  238. <p>[<i>Note:</i> This constitutes an &quot;as if&quot; rule for implementation of
  239. operating system dependent behavior. In practice implementations will usually call native
  240. operating system API's. <i>—end note</i>]</p>
  241. </blockquote>
  242. <p>Implementations are encouraged to provide such behavior
  243. as it is defined by ISO/IEC 9945. Implementations shall document any
  244. behavior that differs from the behavior defined by ISO/IEC 9945. Implementations that do not support exact
  245. ISO/IEC 9945 behavior are
  246. encouraged to provide behavior as close to ISO/IEC 9945 behavior as is reasonable given the
  247. limitations of actual operating systems and file systems. If an implementation cannot provide any
  248. reasonable behavior, the implementation shall report an error in an
  249. implementation-defined manner.</p>
  250. <blockquote>
  251. <p>[<i>Note:</i> Such errors might be reported by an #error directive, a <code>
  252. static_assert</code>, a <code>filesystem_error</code> exception, a special
  253. return value, or some other manner. <i>—end note</i>]</p>
  254. </blockquote>
  255. <p>Implementations are not required to provide behavior that is not supported by
  256. a particular file system.</p>
  257. <blockquote>
  258. <p>[<i>Example:</i> The <a href="http://en.wikipedia.org/wiki/FAT_filesystem">
  259. FAT file system</a> used by some memory cards, camera memory, and floppy discs
  260. does not support hard links, symlinks, and many other features of more capable
  261. file systems. Implementations are only required to support the FAT features
  262. supported by the host operating system. <i>—end example</i>]</p>
  263. </blockquote>
  264. <p>The behavior of functions described in this
  265. reference
  266. may differ from their specification in
  267. the presence of <a href="#file-system-race">file system races</a>. No diagnostic is required.</p>
  268. <p>If the possibility of a file system race would make it unreliable for a program to
  269. test for a precondition before calling a function described in this reference documentation, <i>
  270. Requires</i> is not specified for the condition. Instead, the condition is
  271. specified as a <i>Throws</i> condition.</p>
  272. <blockquote>
  273. <p>[<i>Note:</i> As a design practice, preconditions are not specified when it
  274. is unreasonable for a program to detect them prior to calling the function. <i>
  275. —end note</i>]</p>
  276. </blockquote>
  277. <h3>Operating system dependent conformance [fs.conform.os]</h3>
  278. <p>Some behavior is specified in this reference documentation as being
  279. operating system dependent ([fs.def.osdep]). The operation system an
  280. implementation is dependent upon is implementation defined.</p>
  281. <p>It is permissible for an implementation to be dependent upon an operating
  282. system emulator rather than the actual operating system.</p>
  283. <blockquote>
  284. <p>[<i>Example:</i> An implementation uses Cygwin, a Linux&reg; API emulator for
  285. some Windows&reg; operating system versions. The implementation would define Cygwin
  286. as its operating system. Users could refer to the Cygwin documentation to find
  287. details of the operating system dependent behavior.&nbsp; <i>—end example</i>]</p>
  288. <p><span style="background-color: #E0E0E0"><i>It is user and conformance test
  289. detectable that such an implementation is running on Cygwin. Users would be
  290. misled and conformance tests would fail if the implementation defined Linux or
  291. Windows rather than Cygwin as the operating system, since real behavior is a
  292. blend of the two.</i></span> </p>
  293. </blockquote>
  294. <h2><a name="Definitions">Definitions</a> [fs.definitions]</h2>
  295. <p>The following definitions shall apply throughout this reference documentation:</p>
  296. <h3><a name="operating system dependent">operating system dependent</a> behavior
  297. [fs.def.osdep]</h3>
  298. <p>Behavior that is dependent upon the behavior
  299. and characteristics of an operating system. See [fs.conform.os].</p>
  300. <h3><a name="file">file</a> [fs.def.file]</h3>
  301. <p>An object that can be written to, or read from, or both. A file
  302. has certain attributes, including type. File types include regular files
  303. and directories. Other types of files, such as symbolic links, may be supported by the
  304. implementation.</p>
  305. <h3><a name="file-system">file system</a> [fs.def.filesystem]</h3>
  306. <p>A collection of files and certain of their attributes.</p>
  307. <h3><a name="filename">filename</a> [fs.def.filename]</h3>
  308. <p>The name of a file. Filenames <code>
  309. &quot;.&quot;</code>&nbsp;
  310. and <code>&quot;..&quot;</code>&nbsp; have special meaning. The follow characteristics of
  311. filenames are operating system dependent:</p>
  312. <ul>
  313. <li>
  314. <p>The permitted characters. See [<a href="#Operating-system-examples">fs.os.examples</a>].</p>
  315. </li>
  316. <li>
  317. <p>Specific filenames that are not permitted.</p>
  318. </li>
  319. <li>
  320. <p>Additional filenames that have special meaning.</p>
  321. </li>
  322. <li>
  323. <p>Case awareness and sensitivity during path resolution.</p>
  324. </li>
  325. <li>
  326. <p>Special rules that may apply to file types other than regular
  327. files, such as directories.</p>
  328. </li>
  329. </ul>
  330. <h3><a name="path">path</a> [fs.def.path]</h3>
  331. <p>A sequence of elements that identify
  332. the location of a file within a filesystem. The elements are the <i>root-name<sub>opt</sub></i>, <i>
  333. root-directory<sub>opt</sub></i>, and an optional sequence of filenames. [<i>Note:</i>
  334. A <a href="#pathname">pathname</a> is the concrete representation of a path. <i>—end note</i>]</p>
  335. <h3><a name="Absolute-path">absolute path</a> [fs.def.absolute-path]</h3>
  336. <p>A path that
  337. unambiguously
  338. identifies the location of a file without reference to an additional starting
  339. location. The elements of a path that determine if it is absolute are
  340. operating system dependent.</p>
  341. <h3><a name="Relative-path">relative path</a> [fs.def.relative-path]</h3>
  342. <p>A path that
  343. is not absolute, and so only
  344. unambiguously
  345. identifies the location of a file when resolved relative to
  346. an implied starting location. The elements of a path that determine if it is
  347. relative are operating system dependent.&nbsp; [<i>Note:</i>
  348. Paths <code>&quot;.&quot;</code> and <code>&quot;..&quot;</code> are relative paths. <i>—end note</i>]</p>
  349. <h3><a name="canonical-path">canonical path</a> [fs.def.canonical-path]</h3>
  350. <p>An absolute path that has
  351. no elements that are symbolic links, and no <code>&quot;.&quot;</code> or <code>&quot;..&quot;</code> elements.</p>
  352. <h3><a name="pathname">pathname</a> [fs.def.pathname]</h3>
  353. <p>A character string that represents
  354. the name of a
  355. path. Pathnames are formatted according to the generic pathname grammar or an
  356. operating system dependent
  357. native pathname format.</p>
  358. <h3><a name="native-pathname-format">native pathname format</a> [fs.def.native]</h3>
  359. <p>The operating system dependent pathname format accepted by the host operating system.</p>
  360. <h3><a name="normal-form">normal form</a> path [fs.def.normal]</h3>
  361. <p>A path with no redundant current directory (<i>dot</i>) or parent directory (<i>dot-dot</i>)
  362. elements. The normal form for an empty path is an empty path. The normal form
  363. for a path ending in a <i>directory-separator</i> that is not the root directory
  364. is the same path with a current directory (<i>dot</i>) element appended.</p>
  365. <h3><a name="link">link</a> [fs.def.link]</h3>
  366. <p>A directory entry object that associates a
  367. filename with a file. On some file systems, several directory entries can
  368. associate names with the same file.</p>
  369. <h3><a name="hard-link">hard link</a> [fs.def.hardlink]</h3>
  370. <p>A link to an existing file. Some
  371. file systems support multiple hard links to a file. If the last hard link to a
  372. file is removed, the file itself is removed.</p>
  373. <blockquote>
  374. <p>[<i>Note:</i> A hard link can be thought of as a shared-ownership smart
  375. pointer to a file.<i> —end note</i>]<i> </i></p>
  376. </blockquote>
  377. <h3><a name="symbolic-link">symbolic link</a> [fs.def.symlink]</h3>
  378. <p>A type of file with the
  379. property that when the file is encountered during pathname resolution, a string
  380. stored by the file is used to modify the pathname resolution.</p>
  381. <blockquote>
  382. <p>[<i>Note:</i> A symbolic link can be thought of as a raw pointer to a file.
  383. If the file pointed to does not exist, the symbolic link is said to be a
  384. &quot;dangling&quot; symbolic link.<i> —end note</i>]<i> </i></p>
  385. </blockquote>
  386. <h3><a name="file-system-race">file system race</a> [fs.def.race]</h3>
  387. <p>The condition that occurs
  388. when multiple threads, processes, or computers interleave access and
  389. modification of
  390. the same object within a file system.</p>
  391. <h2><a name="generic-pathname-format">Generic pathname format</a> [path.generic]</h2>
  392. <p><i>pathname:<br>
  393. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; root-name<sub>opt</sub>
  394. root-directory<sub>opt</sub> relative-path<sub>opt</sub></i></p>
  395. <p><i>root-name:<br>
  396. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </i>An
  397. operating system dependent name that identifies the starting location for
  398. absolute paths. </p>
  399. <blockquote>
  400. <blockquote>
  401. <p>[<i>Note:</i> Many operating systems define a name
  402. beginning with two <i>directory-separator</i> characters as a <i>root-name</i>
  403. that identifies network or other resource locations. Some operating systems define a single letter followed by a colon as a drive
  404. specifier - a <i>root-name</i> identifying a specific device such as a disc drive. <i>—end note</i>]</p>
  405. </blockquote>
  406. </blockquote>
  407. <p><i>root-directory:<br>
  408. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  409. directory-separator</i></p>
  410. <p><i>relative-path:<br>
  411. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  412. filename<br>
  413. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; relative-path
  414. directory-separator<br>
  415. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; relative-path
  416. directory-separator filename</i></p>
  417. <p><i>filename:<br>
  418. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; name<br>
  419. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </i><code>&quot;.&quot;</code><i><br>
  420. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </i><code>
  421. &quot;..&quot;</code></p>
  422. <p><i>preferred-separator:<br>
  423. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </i>An
  424. operating system dependent directory separator character. May be a synonym for <i> <code>&quot;/&quot;</code>.</i></p>
  425. <p><i>directory-separator:<br>
  426. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <code>&quot;/&quot;<br>
  427. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;/&quot;</code> directory-separator<br>
  428. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  429. preferred-separator<br>
  430. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  431. preferred-separator directory-separator</i></p>
  432. <p>Multiple successive <i>directory-separator</i> characters are considered to
  433. be the same as one <i>directory-separator</i> character.</p>
  434. <p>The <i>filename</i>
  435. <code>&quot;.&quot;</code> is considered to be a reference to the current directory. The
  436. <i>filename</i> <code>&quot;..&quot;</code> is considered to be a reference to the
  437. parent
  438. directory. Specific <i>filenames</i> may have special meanings for a particular
  439. operating system.</p>
  440. <h2><a name="Operating-system-examples">Operating system dependent examples</a> (Informative) [fs.os.examples]</h2>
  441. <p>Certain features are specified in this reference documentation as being operating system dependent. The following table shows the application of those
  442. specifications for operating systems that use the ISO/IEC 9945 or Windows&reg; application program interfaces
  443. (APIs).<sup>[footnote1]</sup></p>
  444. <table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111">
  445. <tr>
  446. <td valign="top" align="center">
  447. <p><b>Feature</b></td>
  448. <td valign="top" align="center">
  449. <p><b>Section</b></td>
  450. <td valign="top" align="center">
  451. <p><b>ISO/IEC 9945<br>
  452. &nbsp;POSIX</b>&reg;<b> API</b></td>
  453. <td valign="top" align="center">
  454. <p><b>Windows</b>&reg;<b> API</b></td>
  455. <td valign="top" align="center">
  456. <p><b>Notes</b></td>
  457. </tr>
  458. <tr>
  459. <td valign="top">
  460. <p><code>path<br>
  461. &nbsp;::value_type</code></td>
  462. <td valign="top">
  463. <p>[<a href="#class-path">class.path</a>]</td>
  464. <td valign="top">
  465. <p><code>char</code></td>
  466. <td valign="top">
  467. <p><code>wchar_t</code></td>
  468. <td valign="top">
  469. <p>&nbsp;</td>
  470. </tr>
  471. <tr>
  472. <td valign="top">
  473. <p><code>path::preferred<br>
  474. &nbsp;_separator</code></td>
  475. <td valign="top">
  476. <p>[<a href="#class-path">class.path</a>]</td>
  477. <td valign="top">
  478. <p><code>'/'</code></td>
  479. <td valign="top">
  480. <p><code>L'\\'</code> (single backslash)</td>
  481. <td valign="top">
  482. <p>&nbsp;</td>
  483. </tr>
  484. <tr>
  485. <td valign="top">
  486. <p><code>path(&quot;/&quot;)<br>
  487. &nbsp;.is_absolute()<br>
  488. path(&quot;c:/&quot;)<br>
  489. &nbsp;.is_absolute()</code></td>
  490. <td valign="top">
  491. <p>[<a href="#path-query">path</a><br>
  492. &nbsp;<a href="#path-query">.query</a>]</td>
  493. <td valign="top">
  494. <p><code><br>
  495. true<br>
  496. <br>
  497. false</code></td>
  498. <td valign="top">
  499. <p><code><br>
  500. false<br>
  501. <br>
  502. true</code></td>
  503. <td valign="top">
  504. <p>&nbsp;</td>
  505. </tr>
  506. <tr>
  507. <td valign="top">
  508. <p><code>path</code> argument disambiguation between generic format and
  509. native format</td>
  510. <td valign="top">
  511. <p>[<a href="#path-Conversions-to-native-format">path.arg</a><br>
  512. &nbsp;<a href="#path-Conversions-to-native-format">.fmt.cvt</a>]</td>
  513. <td valign="top">
  514. <p>Not required</td>
  515. <td valign="top">
  516. <p>Not required</td>
  517. <td valign="top">
  518. <p>There is no need to distinguish between the generic format and native
  519. format for these operating systems.</td>
  520. </tr>
  521. <tr>
  522. <td valign="top">
  523. <p><code>path</code> argument format conversion</td>
  524. <td valign="top">
  525. <p>[<a href="#path-Conversions-to-native-format">path.arg</a><br>
  526. &nbsp;<a href="#path-Conversions-to-native-format">.fmt.cvt</a>]</td>
  527. <td valign="top">
  528. <p>No conversion performed</td>
  529. <td valign="top">
  530. <p>No conversion performed</td>
  531. <td valign="top">
  532. <p>The generic format is already acceptable to the native API of these operating systems.</td>
  533. </tr>
  534. <tr>
  535. <td valign="top">
  536. <p><code>path<br>
  537. &nbsp;(&quot;/cats/jane&quot;)<br>
  538. &nbsp;.c_str()<br>
  539. path|<br>
  540. &nbsp;(&quot;/cats/jane/&quot;)<br>
  541. &nbsp;.c_str()</code></td>
  542. <td valign="top">
  543. <p>[<a href="#path-Conversions-to-native-format">path.arg</a><br>
  544. &nbsp;<a href="#path-Conversions-to-native-format">.fmt.cvt</a>]</td>
  545. <td valign="top">
  546. <p> <code><br>
  547. <br>
  548. &quot;/cats/jane&quot;<br>
  549. <br>
  550. <br>
  551. &quot;/cats/jane/&quot;</code></td>
  552. <td valign="top">
  553. <p><code><br>
  554. <br>
  555. L&quot;/cats/jane&quot;<br>
  556. <br>
  557. <br>
  558. L&quot;/cats/jane/&quot;</code></td>
  559. <td valign="top">
  560. <p>These operating systems accept the same native separator between
  561. directory names and a final file name, so no format conversion is performed.
  562. Other operating systems might require conversion.</td>
  563. </tr>
  564. <tr>
  565. <td valign="top">
  566. <p>Format conversion by <code>path</code> native format observers</td>
  567. <td valign="top">
  568. <p>[<a href="#path-native-format-observers">path.native</a><br>
  569. &nbsp;<a href="#path-native-format-observers">.obs</a>]</td>
  570. <td valign="top">
  571. <p>No conversion performed</td>
  572. <td valign="top">
  573. <p>No conversion performed</td>
  574. <td valign="top">
  575. <p>For efficiency, <code>path</code> objects are required to store pathnames in the native
  576. format regardless of operating system.</td>
  577. </tr>
  578. <tr>
  579. <td valign="top">
  580. <p>Format conversion by <code>path</code> generic format observers</td>
  581. <td valign="top">
  582. <p>[<a href="#path-generic-format-observers">path</a><br>
  583. &nbsp;<a href="#path-generic-format-observers">.generic</a><br>
  584. &nbsp;<a href="#path-generic-format-observers">.obs</a>]</td>
  585. <td valign="top">
  586. <p>No conversion performed</td>
  587. <td valign="top">
  588. <p>Backslashes converted to slashes</td>
  589. <td valign="top">
  590. <p>&nbsp;</td>
  591. </tr>
  592. <tr>
  593. <td valign="top">
  594. <p><code>p.<br>
  595. &nbsp;make_preferred()</code></td>
  596. <td valign="top">
  597. <p>[<a href="#path-modifiers">fs.path</a><br>
  598. &nbsp;<a href="#path-modifiers">.modifiers</a>]</td>
  599. <td valign="top">
  600. <p>No change</td>
  601. <td valign="top">
  602. <p>Slashes converted to backslashes</td>
  603. <td valign="top">
  604. <p>&nbsp;</td>
  605. </tr>
  606. <tr>
  607. <td valign="top">
  608. <p>Characters prohibited in filenames</td>
  609. <td valign="top">
  610. <p>[<a href="#filename">fs.def</a><br>
  611. &nbsp;<a href="#filename">.filename</a>]</td>
  612. <td valign="top">
  613. <p>0x00, <code>'/'</code></td>
  614. <td valign="top">
  615. <p>0x00-0x1F, <code>'&quot;'</code>, <code>'*'</code>,<code>&nbsp;'*'</code>,
  616. <code>'&lt;'</code>,
  617. <code>'&gt;'</code>, <code>'?'</code>, <code>'\\'</code> (single backslash),
  618. <code>'/'</code>, <code>'|'</code></td>
  619. <td valign="top">
  620. <p>Many operating systems prohibit the ASCII control characters (0x00-0x1F)
  621. in filenames.</td>
  622. </tr>
  623. <tr>
  624. <td valign="top">
  625. <p>Initial imbued <code>path</code> locale</td>
  626. <td valign="top">
  627. <p>[<a href="#path-imbued-locale">path</a><br>
  628. &nbsp;<a href="#path-imbued-locale">.imbued</a><br>
  629. &nbsp;<a href="#path-imbued-locale">.locale</a>]</td>
  630. <td valign="top">
  631. <p> <code>std::<br>
  632. &nbsp; locale(&quot;&quot;)<br>
  633. </code><sup>[footnote 2]</sup></td>
  634. <td valign="top">
  635. <p>Implementation supplied locale using <code>MultiByte<br>
  636. &nbsp; ToWideChar</code>
  637. and <code>WideChar<br>
  638. &nbsp; ToMultiByte</code> with a codepage of <code>CP_ACP</code>
  639. if <code>AreFileApisANSI</code> is true, otherwise codepage <code>CP_OEMCP</code>.<sup>[footnote
  640. 3]</sup></td>
  641. <td valign="top">
  642. <p>Apple OS X&reg;:&nbsp; Implementation supplied locale providing UTF-8 <code>codecvt</code>
  643. facet.<sup>[footnote 4]</sup></td>
  644. </tr>
  645. </table>
  646. <p><sup>[footnote1]</sup> OS X&reg; and Windows&reg; are examples of commercially
  647. available operating systems. This information is given for the convenience of
  648. users of this document and does not constitute an endorsement by ISO or IEC of
  649. these products.</p>
  650. <p><sup>[footnote 2] </sup>Rationale: ISO C specifies <code>std::locale(&quot;&quot;)</code> as &quot;the locale-specific native
  651. environment&quot;, while ISO/IEC 9945 says it &quot;Specifies an implementation-defined native
  652. environment.&quot;</p>
  653. <p><sup>[footnote 3] </sup>Rationale: This is the current behavior of C and C++
  654. standard library functions that perform file operations using narrow character
  655. strings to identify paths. Changing this behavior would be surprising and at
  656. variance with existing code, particularly where user input is involved.</p>
  657. <p><sup>[footnote 4]</sup> Rationale: Vendor's documentation states &quot;All BSD
  658. system functions expect their string parameters to be in UTF-8 encoding and
  659. nothing else.&quot;</p>
  660. <h2><a name="Header-filesystem-synopsis">Header <code>&lt;boost/filesystem.hpp&gt;</code> synopsis</a>
  661. [filesystem.synopsis]</h2>
  662. <pre>namespace boost
  663. {
  664. namespace filesystem
  665. {
  666. class <a href="#class-path">path</a>;
  667. bool lexicographical_compare(path::iterator first1, path::iterator last1,
  668. path::iterator first2, path::iterator last2);
  669. void swap(path&amp; lhs, path&amp; rhs);
  670. std::size_t <a href="#hash_value">hash_value</a>(const path&amp; p);
  671. bool operator==(const path&amp; lhs, const path&amp; rhs);
  672. bool operator!=(const path&amp; lhs, const path&amp; rhs);
  673. bool operator&lt; (const path&amp; lhs, const path&amp; rhs);
  674. bool operator&lt;=(const path&amp; lhs, const path&amp; rhs);
  675. bool operator&gt; (const path&amp; lhs, const path&amp; rhs);
  676. bool operator&gt;=(const path&amp; lhs, const path&amp; rhs);
  677. path operator/ (const path&amp; lhs, const path&amp; rhs);
  678. std::ostream&amp; operator&lt;&lt;( std::ostream&amp; os, const path&amp; p );
  679. std::wostream&amp; operator&lt;&lt;( std::wostream&amp; os, const path&amp; p );
  680. std::istream&amp; operator&gt;&gt;( std::istream&amp; is, path&amp; p );
  681. std::wistream&amp; operator&gt;&gt;( std::wistream&amp; is, path&amp; p )
  682. class <a href="#Class-filesystem_error">filesystem_error</a>;
  683. class <a href="#Class-directory_entry">directory_entry</a>;
  684. class <a href="#Class-directory_iterator">directory_iterator</a>;
  685. // enable c++11 range-based for statements
  686. const directory_iterator&amp; <a href="#directory_iterator-non-member-functions">begin</a>(const directory_iterator&amp; iter);
  687. directory_iterator <a href="#directory_iterator-non-member-functions">end</a>(const directory_iterator&amp;);
  688. // enable BOOST_FOREACH
  689. directory_iterator&amp; range_begin(directory_iterator&amp; iter);
  690. directory_iterator range_begin(const directory_iterator&amp; iter);
  691. directory_iterator range_end(const directory_iterator&amp;);
  692. class <a href="#Class-recursive_directory_iterator">recursive_directory_iterator</a>;
  693. // enable c++11 range-based for statements
  694. const recursive_directory_iterator&amp;
  695. <a href="#recursive_directory_iterator-non-member-functions">begin</a>(const recursive_directory_iterator&amp; iter);
  696. recursive_directory_iterator
  697. <a href="#recursive_directory_iterator-non-member-functions">end</a>(const recursive_directory_iterator&amp;);
  698. // enable BOOST_FOREACH
  699. recursive_directory_iterator&amp;
  700. range_begin(recursive_directory_iterator&amp; iter);
  701. recursive_directory_iterator
  702. range_begin(const recursive_directory_iterator&amp; iter);
  703. recursive_directory_iterator
  704. range_end(const recursive_directory_iterator&amp;);
  705. enum <a name="file_type" href="#Enum-file_type">file_type</a>
  706. {
  707. status_error, file_not_found, regular_file, directory_file,
  708. symlink_file, block_file, character_file, fifo_file, socket_file,
  709. type_unknown
  710. };
  711. enum <a href="#Enum-perms">perms</a>
  712. {
  713. no_perms,
  714. owner_read, owner_write, owner_exe, owner_all,
  715. group_read, group_write, group_exe, group_all,
  716. others_read, others_write, others_exe, others_all, all_all,
  717. set_uid_on_exe, set_gid_on_exe, sticky_bit,
  718. perms_mask, perms_not_known,
  719. add_perms, remove_perms, symlink_perms
  720. };
  721. class <a href="#file_status">file_status</a>;
  722. struct <a name="space_info">space_info</a> // returned by <a href="#space" style="text-decoration: none">space</a> function
  723. {
  724. uintmax_t capacity;
  725. uintmax_t free;
  726. uintmax_t available; // free space available to non-privileged process
  727. };
  728. enum class <a name="copy_option">copy_option</a>
  729. {
  730. none
  731. fail_if_exists = none,
  732. overwrite_if_exists
  733. };
  734. enum class <a name="directory_options">directory_options</a>
  735. {
  736. none
  737. skip_permission_denied,
  738. follow_directory_symlink,
  739. pop_on_error
  740. };
  741. // Deprecated, use <a href="#directory_options">directory_options</a> instead
  742. enum class <a name="symlink_option">symlink_option</a>
  743. {
  744. none = directory_options::none
  745. no_recurse = none,
  746. recurse = directory_options::follow_directory_symlink
  747. };
  748. // <a href="#Operational-functions">operational functions</a>
  749. path <a href="#absolute">absolute</a>(const path&amp; p, const path&amp; base=current_path());
  750. path <a href="#canonical">canonical</a>(const path&amp; p, const path&amp; base = current_path());
  751. path <a href="#canonical">canonical</a>(const path&amp; p, system::error_code&amp; ec);
  752. path <a href="#canonical">canonical</a>(const path&amp; p, const path&amp; base,
  753. system::error_code&amp; ec);
  754. void <a href="#copy">copy</a>(const path&amp; from, const path&amp; to);
  755. void <a href="#copy">copy</a>(const path&amp; from, const path&amp; to,
  756. system::error_code&amp; ec);
  757. void <a href="#create_directory">copy_directory</a>(const path&amp; from, const path&amp; to);
  758. void <a href="#create_directory">copy_directory</a>(const path&amp; from, const path&amp; to,
  759. system::error_code&amp; ec);
  760. void <a href="#copy_file">copy_file</a>(const path&amp; from, const path&amp; to);
  761. void <a href="#copy_file">copy_file</a>(const path&amp; from, const path&amp; to,
  762. system::error_code&amp; ec);
  763. void <a href="#copy_file">copy_file</a>(const path&amp; from, const path&amp; to,
  764. <a href="#copy_option">copy_option</a> option);
  765. void <a href="#copy_file">copy_file</a>(const path&amp; from, const path&amp; to,
  766. <a href="#copy_option">copy_option</a> option, system::error_code&amp; ec);
  767. void <a href="#copy_symlink">copy_symlink</a>(const path&amp; existing_symlink,
  768. const path&amp; new_symlink);
  769. void <a href="#copy_symlink">copy_symlink</a>(const path&amp; existing_symlink,
  770. const path&amp; new_symlink, system::error_code&amp; ec);
  771. bool <a href="#create_directories">create_directories</a>(const path&amp; p);
  772. bool <a href="#create_directories">create_directories</a>(const path&amp; p,
  773. system::error_code&amp; ec);
  774. bool <a href="#create_directory">create_directory</a>(const path&amp; p);
  775. bool <a href="#create_directory">create_directory</a>(const path&amp; p, system::error_code&amp; ec);
  776. void <a href="#create_directory_symlink">create_directory_symlink</a>(const path&amp; to,
  777. const path&amp; new_symlink);
  778. void <a href="#create_directory_symlink">create_directory_symlink</a>(const path&amp; to,
  779. const path&amp; new_symlink, system::error_code&amp; ec);
  780. void <a href="#create_hard_link">create_hard_link</a>(const path&amp; to, const path&amp; new_hard_link);
  781. void <a href="#create_hard_link">create_hard_link</a>(const path&amp; to, const path&amp; new_hard_link,
  782. system::error_code&amp; ec);
  783. void <a href="#create_symlink">create_symlink</a>(const path&amp; to, const path&amp; new_symlink);
  784. void <a href="#create_symlink">create_symlink</a>(const path&amp; to, const path&amp; new_symlink,
  785. system::error_code&amp; ec);
  786. path <a href="#current_path">current_path</a>();
  787. path <a href="#current_path">current_path</a>(system::error_code&amp; ec);
  788. void <a href="#current_path">current_path</a>(const path&amp; p);
  789. void <a href="#current_path">current_path</a>(const path&amp; p, system::error_code&amp; ec);
  790. bool <a href="#exists">exists</a>(file_status s) noexcept;
  791. bool <a href="#exists">exists</a>(const path&amp; p);
  792. bool <a href="#exists">exists</a>(const path&amp; p, system::error_code&amp; ec) noexcept;
  793. bool <a href="#equivalent">equivalent</a>(const path&amp; p1, const path&amp; p2);
  794. bool <a href="#equivalent">equivalent</a>(const path&amp; p1, const path&amp; p2,
  795. system::error_code&amp; ec);
  796. uintmax_t <a href="#file_size">file_size</a>(const path&amp; p);
  797. uintmax_t <a href="#file_size">file_size</a>(const path&amp; p, system::error_code&amp; ec);
  798. uintmax_t <a href="#hard_link_count">hard_link_count</a>(const path&amp; p);
  799. uintmax_t <a href="#hard_link_count">hard_link_count</a>(const path&amp; p, system::error_code&amp; ec);
  800. const path&amp; <a href="#initial_path">initial_path</a>();
  801. const path&amp; <a href="#initial_path">initial_path</a>(<code>system::error_code&amp; ec</code>);
  802. bool <a href="#is_directory">is_directory</a>(file_status s) noexcept;
  803. bool <a href="#is_directory2">is_directory</a>(const path&amp; p);
  804. bool <a href="#is_directory2">is_directory</a>(const path&amp; p,
  805. system::error_code&amp; ec) noexcept;
  806. bool <a href="#is_empty">is_empty</a>(const path&amp; p);
  807. bool <a href="#is_empty">is_empty</a>(const path&amp; p, system::error_code&amp; ec);
  808. bool <a href="#is_other">is_other</a>(file_status s) noexcept;
  809. bool <a href="#is_other2">is_other</a>(const path&amp; p,);
  810. bool <a href="#is_other2">is_other</a>(const path&amp; p, system::error_code&amp; ec) noexcept;
  811. bool <a href="#is_regular_file">is_regular_file</a>(file_status s) noexcept;
  812. bool <a href="#is_regular_file2">is_regular_file</a>(const path&amp; p);
  813. bool <a href="#is_regular_file2">is_regular_file</a>(const path&amp; p,
  814. system::error_code&amp; ec) noexcept;
  815. bool <a href="#is_symlink">is_symlink</a>(file_status s noexcept);
  816. bool <a href="#is_symlink2">is_symlink</a>(const path&amp; p);
  817. bool <a href="#is_symlink2">is_symlink</a>(const path&amp; p, system::error_code&amp; ec) noexcept;
  818. std::time_t <a href="#last_write_time">last_write_time</a>(const path&amp; p);
  819. std::time_t <a href="#last_write_time">last_write_time</a>(const path&amp; p, system::error_code&amp; ec);
  820. void <a href="#last_write_time2">last_write_time</a>(const path&amp; p, const std::time_t new_time);
  821. void <a href="#last_write_time2">last_write_time</a>(const path&amp; p, const std::time_t new_time,
  822. system::error_code&amp; ec);
  823. path <a href="#read_symlink">read_symlink</a>(const path&amp; p);
  824. path <a href="#read_symlink">read_symlink</a>(const path&amp; p, system::error_code&amp; ec);
  825. path <a href="#op-relative">relative</a>(const path&amp; p, system::error_code&amp; ec);
  826. path <a href="#op-relative">relative</a>(const path&amp; p, const path&amp; base=current_path());
  827. path <a href="#op-relative">relative</a>(const path&amp; p,
  828. const path&amp; base, system::error_code&amp; ec);
  829. bool <a href="#remove">remove</a>(const path&amp; p);
  830. bool <a href="#remove">remove</a>(const path&amp; p, system::error_code&amp; ec);
  831. uintmax_t <a href="#remove_all">remove_all</a>(const path&amp; p);
  832. uintmax_t <a href="#remove_all">remove_all</a>(const path&amp; p, system::error_code&amp; ec);
  833. void <a href="#rename">rename</a>(const path&amp; from, const path&amp; to);
  834. void <a href="#rename">rename</a>(const path&amp; from, const path&amp; to,
  835. system::error_code&amp; ec);
  836. void <a href="#resize_file">resize_file</a>(const path&amp; p, uintmax_t size);
  837. void <a href="#resize_file2">resize_file</a>(const path&amp; p, uintmax_t size,
  838. system::error_code&amp; ec);
  839. <a href="#space_info">space_info</a> <a href="#space">space</a>(const path&amp; p);
  840. <a href="#space_info">space_info</a> <a href="#space">space</a>(const path&amp; p, system::error_code&amp; ec);
  841. <a href="#file_status">file_status</a> <a href="#status">status</a>(const path&amp; p);
  842. <a href="#file_status">file_status</a> <a href="#status">status</a>(const path&amp; p, system::error_code&amp; ec) noexcept;
  843. bool <a href="#status_known">status_known</a>(file_status s) noexcept;
  844. <a href="#file_status">file_status</a> <a href="#symlink_status">symlink_status</a>(const path&amp; p);
  845. <a href="#file_status">file_status</a> <a href="#symlink_status">symlink_status</a>(const path&amp; p,
  846. system::error_code&amp; ec) noexcept;
  847. path <a href="#system_complete">system_complete</a>(const path&amp; p);
  848. path <a href="#system_complete">system_complete</a>(const path&amp; p, system::error_code&amp; ec);
  849. path <a href="#temp_directory_path">temp_directory_path</a>();
  850. path <a href="#temp_directory_path">temp_directory_path</a>(system::error_code&amp; ec);
  851. path <a href="#unique_path">unique_path</a>(const path&amp; model=&quot;%%%%-%%%%-%%%%-%%%%&quot;);
  852. path <a href="#unique_path">unique_path</a>(const path&amp; model, system::error_code&amp; ec);
  853. path <a href="#weakly_canonical">weakly_canonical</a>(const path&amp; p);
  854. path <a href="#weakly_canonical">weakly_canonical</a>(const path&amp; p, system::error_code&amp; ec);
  855. } // namespace filesystem
  856. } // namespace boost</pre>
  857. <h2><a name="Error-reporting">Error reporting</a> [fs.err.report]</h2>
  858. <p>Filesystem library functions often provide two overloads, one that
  859. throws an exception to report file system errors, and another that sets an <code>error_code</code>.</p>
  860. <blockquote>
  861. <p>[<i>Note:</i> This supports two common use cases:</p>
  862. <ul>
  863. <li>
  864. <p>Uses where file system
  865. errors are truly exceptional and indicate a serious failure. Throwing an
  866. exception is the most appropriate response. This is the preferred default for
  867. most everyday programming.<br>
  868. &nbsp;</li>
  869. <li>
  870. <p>Uses where file system errors are routine and do not necessarily represent
  871. failure. Returning an error code is the most appropriate response. This allows
  872. application specific error handling, including simply ignoring the error.</li>
  873. </ul>
  874. <p><i>—end note</i>]</p>
  875. </blockquote>
  876. <p>Functions <b>not</b> having an argument of type <code>system::error_code&amp;</code> report errors as follows, unless otherwise specified:</p>
  877. <ul>
  878. <li>
  879. <p>When a call by the
  880. implementation to an operating system or other underlying API results in an
  881. error that prevents the function from meeting its specifications, an exception
  882. of type
  883. <code>filesystem_error</code> is thrown.<br>
  884. &nbsp;</li>
  885. <li>
  886. <p>Failure to allocate storage is reported by throwing an exception as described in the C++ standard,
  887. 17.6.4.10 [res.on.exception.handling].<br>
  888. &nbsp;</li>
  889. <li>
  890. <p>Destructors throw nothing.</li>
  891. </ul>
  892. <p>Functions having an argument of type <code>system::error_code&amp;</code> report errors as follows, unless otherwise
  893. specified:</p>
  894. <ul>
  895. <li>
  896. <p>If a call by the
  897. implementation to an operating system or other underlying API results in an
  898. error that prevents the function from meeting its specifications, the
  899. <code>system::error_code&amp;</code> argument is set as
  900. appropriate for the specific error. Otherwise, <code>clear()</code>
  901. is called on the
  902. <code>system::error_code&amp;</code> argument.<br>
  903. &nbsp;</li>
  904. <li>
  905. <p>Failure to allocate storage is reported by
  906. throwing an exception as described in the C++ standard,
  907. 17.6.4.10 [res.on.exception.handling].</li>
  908. </ul>
  909. <h2><a name="class-path">Class <code>path</code> [class.path]</a></h2>
  910. <p>An object of class <code>path</code> represents a <a href="#path">path</a>,
  911. and contains a <a href="#pathname">pathname</a> Such an object is concerned only with the lexical and syntactic aspects
  912. of a path. The path does not necessarily exist in external storage, and the
  913. pathname is not necessarily valid for the current operating
  914. system or for a particular file system.</p>
  915. <div dir="ltr">
  916. <pre>namespace boost
  917. {
  918. namespace filesystem
  919. {
  920. class path
  921. {
  922. public:
  923. typedef <b><i><a href="#value_type">see below</a></i></b> value_type;
  924. typedef std::basic_string&lt;value_type&gt; string_type;
  925. typedef std::codecvt&lt;wchar_t, char, std::mbstate_t&gt; codecvt_type;
  926. constexpr value_type dot;
  927. constexpr value_type separator;
  928. constexpr value_type preferred_separator;
  929. // <a href="#path-constructors">constructors</a> and destructor
  930. path();
  931. path(const path&amp; p);
  932. path(path&amp;&amp; p) noexcept;
  933. template &lt;class <a href="#Source">Source</a>&gt;
  934. path(Source const&amp; source, const codecvt_type&amp; cvt=codecvt());
  935. template &lt;class <a href="#InputIterator">InputIterator</a>&gt;
  936. path(InputIterator begin, InputIterator end,
  937. const codecvt_type&amp; cvt=codecvt());
  938. ~path();
  939. // <a href="#path-assignments">assignments</a>
  940. path&amp; operator=(const path&amp; p);
  941. path&amp; operator=(path&amp;&amp; p) noexcept;
  942. template &lt;class <a href="#Source">Source</a>&gt;
  943. path&amp; operator=(Source const&amp; source);
  944. template &lt;class <a href="#Source">Source</a>&gt;
  945. path&amp; assign(Source const&amp; source, const codecvt_type&amp; cvt)
  946. template &lt;class <a href="#InputIterator">InputIterator</a>&gt;
  947. path&amp; assign(InputIterator begin, InputIterator end,
  948. const codecvt_type&amp; cvt=codecvt());
  949. // <a href="#path-appends">appends</a>
  950. path&amp; operator/=(const path&amp; p);
  951. template &lt;class <a href="#Source">Source</a>&gt;
  952. path&amp; operator/=(Source const&amp; source);
  953. template &lt;class <a href="#Source">Source</a>&gt;
  954. path&amp; append(Source const&amp; source, const codecvt_type&amp; cvt);
  955. template &lt;class <a href="#InputIterator">InputIterator</a>&gt;
  956. path&amp; append(InputIterator begin, InputIterator end,
  957. const codecvt_type&amp; cvt=codecvt());
  958. // <a href="#path-concatenation">concatenation</a>
  959. path&amp; operator+=(const path&amp; x);
  960. path&amp; operator+=(const string_type&amp; x);
  961. path&amp; operator+=(const value_type* x);
  962. path&amp; operator+=(value_type x);
  963. template &lt;class Source&gt;
  964. path&amp; operator+=(Source const&amp; x);
  965. template &lt;class CharT&gt;
  966. path&amp; operator+=(CharT x);
  967. template &lt;class Source&gt;
  968. path&amp; concat(Source const&amp; x, const codecvt_type&amp; cvt);
  969. template &lt;class InputIterator&gt;
  970. path&amp; concat(InputIterator begin, InputIterator end);
  971. template &lt;class InputIterator&gt;
  972. path&amp; concat(InputIterator begin, InputIterator end,
  973. const codecvt_type&amp; cvt);
  974. // <a href="#path-modifiers">modifiers</a>
  975. void <a href="#path-clear">clear</a>();
  976. path&amp; <a href="#path-make_preferred">make_preferred</a>();
  977. path&amp; <a href="#path-remove_filename">remove_filename</a>();
  978. path&amp; <a href="#path-replace_extension">replace_extension</a>(const path&amp; new_extension = path());
  979. void <a href="#path-swap">swap</a>(path&amp; rhs);
  980. // lexical operations
  981. path <a href="#lexically_normal">lexically_normal</a>() const;
  982. path <a href="#lexically_relative">lexically_relative</a>(const path&amp; base) const;
  983. path <a href="#lexically_proximate">lexically_proximate</a>(const path&amp; base) const;
  984. // <a href="#path-native-format-observers">native format observers</a>
  985. const string_type&amp; <a href="#native">native</a>() const noexcept; // native format, encoding
  986. const value_type* <a href="#c_str">c_str</a>() const noexcept; // native().c_str()
  987. string_type::size_type <a href="#path-size">size</a>() const noexcept; // native().size()
  988. template &lt;class String&gt;
  989. String <a href="#string-template">string</a>(const codecvt_type&amp; cvt=codecvt()) const;
  990. string <a href="#string">string</a>(const codecvt_type&amp; cvt=codecvt()) const;
  991. wstring <a href="#wstring">wstring</a>(const codecvt_type&amp; cvt=codecvt()) const;
  992. u16string <a href="#u16string">u16string</a>() const;
  993. u32string <a href="#u32wstring">u32string</a>() const;
  994. // <a href="#path-generic-format-observers">generic format observers</a>
  995. template &lt;class String&gt;
  996. String <a href="#generic_string-template">generic_string</a>() const;
  997. string <a href="#generic_string">generic_string</a>(const codecvt_type&amp; cvt=codecvt()) const;
  998. wstring <a href="#generic_wstring">generic_wstring</a>(const codecvt_type&amp; cvt=codecvt()) const;
  999. u16string <a href="#generic_u16string">generic_u16string</a>()
  1000. u32string <a href="#generic_u32wstring">generic_u32string</a>()
  1001. // <a href="#path-compare">compare</a>
  1002. int <a href="#path-compare">compare</a>(const path&amp; p) const noexcept;
  1003. int <a href="#path-compare">compare</a>(const std::string&amp; s) const;
  1004. int <a href="#path-compare">compare</a>(const value_type* s) const;
  1005. // <a href="#path-decomposition">decomposition</a>
  1006. path <a href="#path-root_name">root_name</a>() const;
  1007. path <a href="#path-root_directory">root_directory</a>() const;
  1008. path <a href="#path-root_path">root_path</a>() const;
  1009. path <a href="#path-relative_path">relative_path</a>() const;
  1010. path <a href="#path-parent_path">parent_path</a>() const;
  1011. path <a href="#path-filename">filename</a>() const;
  1012. path <a href="#path-stem">stem</a>() const;
  1013. path <a href="#path-extension">extension</a>() const;
  1014. // <a href="#path-query">query</a>
  1015. bool <a href="#path-query">empty</a>() const;
  1016. bool <a href="#filename_is_dot">filename_is_dot</a>() const;
  1017. bool <a href="#filename_is_dot_dot">filename_is_dot_dot</a>() const;
  1018. bool <a href="#path-has_root_name">has_root_name</a>() const;
  1019. bool <a href="#path-has_root_directory">has_root_directory</a>() const;
  1020. bool <a href="#path-has_root_path">has_root_path</a>() const;
  1021. bool <a href="#path-has_relative_path">has_relative_path</a>() const;
  1022. bool <a href="#path-has_parent_path">has_parent_path</a>() const;
  1023. bool <a href="#path-has_filename">has_filename</a>() const;
  1024. bool <a href="#path-has_stem">has_stem</a>() const;
  1025. bool <a href="#path-has_extension">has_extension</a>() const;
  1026. bool <a href="#path-is_absolute">is_absolute</a>() const;
  1027. bool <a href="#path-is_relative">is_relative</a>() const;
  1028. // <a href="#path-iterators">iterators</a>
  1029. class iterator;
  1030. typedef iterator const_iterator;
  1031. class reverse_iterator;
  1032. typedef reverse_iterator const_reverse_iterator;
  1033. iterator begin() const;
  1034. iterator end() const;
  1035. reverse_iterator rbegin() const;
  1036. reverse_iterator rend() const;
  1037. // <a href="#path-imbued-locale">imbued locale</a>
  1038. static std::locale <a href="#path-imbue">imbue</a>(const std::locale&amp; loc);
  1039. static const codecvt_type &amp; <a href="#path-codecvt">codecvt</a>();
  1040. private:
  1041. string_type pathname; // <b><i>exposition only</i></b>
  1042. };
  1043. } // namespace filesystem
  1044. } // namespace boost</pre>
  1045. </div>
  1046. <p><code><a name="value_type">value_type</a></code> is a <code>typedef</code> for the
  1047. character type used by the operating system to represent pathnames.</p>
  1048. <h3><a name="path-Usage"><code>path</code> Usage concerns</a> [path.usage]</h3>
  1049. <h4>Multithreading concerns</h4>
  1050. <p>Filesystem library functions are not protected against data races. [Modifying
  1051. an object of a Filesystem library type that is shared between threads risks
  1052. undefined behavior unless objects of that type are explicitly specified as being
  1053. sharable without data races or the user supplies a locking mechanism. <i>—end
  1054. note</i>] [<i>Note:</i> Thus the Filesystem library behaves as if it were part
  1055. of the standard library, and C++ standard 17.6.4.10 <i>Shared objects and the
  1056. library</i> [res.on.objects] would thus apply.&nbsp; <i>—end note</i>]</p>
  1057. <h4>Windows concerns</h4>
  1058. <p>Visual C++ at least through version 2012 does not employ C++11-style static
  1059. initialization locks, so the initialization of <code>path::codecvt()</code> can
  1060. race, either with itself or <code>path::imbue::()</code> if they are called from
  1061. a different thread. A workaround is to call:</p>
  1062. <blockquote>
  1063. <p><code>path::codecvt();&nbsp; // ensure VC++ does not race during
  1064. initialization.</code></p>
  1065. </blockquote>
  1066. <p>in the main thread before launching any additional threads. [<i>Note:</i> The
  1067. obvious fix of the Filesystem implementation doing the locking doesn't work
  1068. because of unrelated problems with the Microsoft compiler; for static linking
  1069. the runtime tries to do the initialization before main() starts, but doesn't
  1070. permit operating system lock calls at that time.&nbsp; <i>—end note</i>]</p>
  1071. <h4>POSIX concerns</h4>
  1072. <p>Filesystem library initialization may throw an exception on POSIX
  1073. systems (e.g. Linux, but not Mac OS X) that use environmental variables to
  1074. determine the encoding of paths. This happens when <code>std::locale(&quot;&quot;)</code>
  1075. throws because an environmental variable such as LANG is set to an invalid
  1076. value, so it can affect any use of&nbsp; <code>std::locale(&quot;&quot;)</code>, not just
  1077. the Filesystem library. Filesystem uses lazy initialization so the exception is
  1078. only thrown if a valid <code>std::locale(&quot;&quot;)</code> is actually needed, and also
  1079. so that the exception is thrown after <code>main()</code> starts.</p>
  1080. <p>Rather than waiting until a call to some Filesystem library function
  1081. unexpectedly triggers the exception when it calls <code>path::codecvt()</code>,
  1082. a program that needs be highly robust against environmental variable problems
  1083. may want to preemptively call <code>std::locale(&quot;&quot;)</code> within a try block,
  1084. catch the exception, and diagnose or repair the invalid environmental variable.</p>
  1085. <h3><a name="path-Conversions"><code>path</code> Conversions</a> [path.cvt]</h3>
  1086. <h4><code>path</code> argument conversions [<a name="path.arg.convert">path.arg.cvt</a>]</h4>
  1087. <h5><a name="path-Conversions-to-native-format"><code>path</code> argument
  1088. format conversions</a> [path.arg.fmt.cvt]</h5>
  1089. <p>Member function arguments that take character sequences representing paths
  1090. may use the <a href="#generic-pathname-format">generic pathname format</a> or
  1091. the <a href="#native-pathname-format">native pathname format</a>. Iff such arguments
  1092. are in the generic format and the generic format is not acceptable to the
  1093. operating system as a native path, conversion to native format shall be performed
  1094. during the processing of the argument. See [<a href="#Operating-system-examples">fs.os.examples</a>].</p>
  1095. <blockquote>
  1096. <p>[<i>Note:</i> Depending on the operating system, there may be no unambiguous way for an implementation to
  1097. always be able to distinguish between native format and generic format arguments.
  1098. This is by design as it simplifies use for operating systems that do not require
  1099. disambiguation. Should an implementation encounter an
  1100. operating system where disambiguation is required, an implementation can defined
  1101. an extension to distinguish between the formats. <i>
  1102. —end note</i>]</p>
  1103. </blockquote>
  1104. <p>If the native format requires
  1105. paths for regular files to be formatted differently from paths for directories, the
  1106. path shall be treated as a directory path if last element is a separator,
  1107. otherwise it shall be treated as a regular file path.</p>
  1108. <h5><a name="path-Encoding-conversions"><code>
  1109. path</code> argument encoding conversions</a>
  1110. [path.arg.encoding.cvt]</h5>
  1111. <p>For member function arguments that take character sequences representing
  1112. paths, if the value type of the argument is not <code>value_type and </code>one
  1113. of the value types is <code>char</code> and the other is <code>wchar_t</code>, conversion to <code>value_type</code>
  1114. shall be performed by the <code>path::codecvt()</code> facet. ([<a href="#path-imbued-locale">path.imbued.locale</a>]).</p>
  1115. <h4><a name="path-Conversions-to-generic-format"><code>path</code> Conversions
  1116. to generic format</a> [fs.cvt.to.generic]</h4>
  1117. <p><a href="#path-generic-format-observers">Generic format observer</a> functions
  1118. shall return strings formatted according to the <a href="#generic-pathname-format">generic pathname format</a>
  1119. using <i>preferred-separator</i>. See [<a href="#Operating-system-examples">fs.os.examples</a>].</p>
  1120. <h3><a name="path-Requirements"><code>path</code> Requirements</a> [path.req]</h3>
  1121. <p>Template parameters named <code><a name="InputIterator">InputIterator</a></code> are required meet the
  1122. requirements for a C++ standard library <code>RandomIterator</code> compliant iterator. The iterator's value type is required to be <code>char</code>, <code>wchar_t</code>, <code>char16_t</code>, or <code>char32_t</code>.</p>
  1123. <p>Template parameters named <code><a name="Source">Source</a></code> are required to be one of:</p>
  1124. <ul>
  1125. <li>
  1126. <p>A container with a value type of <code>char</code>, <code>
  1127. wchar_t</code>, <code>char16_t</code>, or <code>char32_t</code>.</li>
  1128. <li>
  1129. <p>An iterator for a null terminated byte-string. The value type is required
  1130. to be <code>char</code>, <code>wchar_t</code>, <code>char16_t</code>, or <code>
  1131. char32_t</code>.</li>
  1132. <li>
  1133. <p>A C-array. The value type is required to be <code>char</code>, <code>
  1134. wchar_t</code>, <code>char16_t</code>, or <code>char32_t</code>.</li>
  1135. <li>
  1136. <p>A <code>boost::filesystem::directory_entry</code>.</li>
  1137. </ul>
  1138. <h3> <a name="path-constructors"> <code>
  1139. <font size="4">path</font></code> constructors</a> [path.construct]</h3>
  1140. <pre>template &lt;class <a href="#Source">Source</a>&gt;
  1141. path(Source const&amp; source, const codecvt_type&amp; cvt=codecvt());</pre>
  1142. <pre>template &lt;class <a href="#InputIterator">InputIterator</a>&gt;
  1143. path(InputIterator begin, InputIterator end, const codecvt_type&amp; cvt=codecvt());</pre>
  1144. <blockquote>
  1145. <p><i>Effects:</i> Stores the contents [<code>begin</code>,<code>end</code>)
  1146. or <code>source</code> in <code>pathname</code>, converting format and
  1147. encoding if required ([<a href="#path.arg.convert">path.arg.convert</a>]).</p>
  1148. </blockquote>
  1149. <h3> <a name="path-assignments"> <code>
  1150. <font size="4">path</font></code> assignments</a> [path.assign]</h3>
  1151. <pre>template &lt;class <a href="#Source">Source</a>&gt;
  1152. path&amp; operator=(Source const&amp; source);
  1153. template &lt;class <a href="#Source">Source</a>&gt;
  1154. path&amp; assign(Source const&amp; source, const codecvt_type&amp; cvt);
  1155. template &lt;class <a href="#InputIterator">InputIterator</a>&gt;
  1156. path&amp; assign(InputIterator begin, InputIterator end, const codecvt_type&amp; cvt=codecvt());</pre>
  1157. <blockquote>
  1158. <p><i>Effects:</i> Stores the contents [<code>begin</code>,<code>end</code>)
  1159. or <code>source</code> in <code>pathname</code>, converting format and
  1160. encoding if required ([<a href="#path.arg.convert">path.arg.convert</a>]). </p>
  1161. <p>
  1162. <i>Returns: </i><code>*this</code></p>
  1163. </blockquote>
  1164. <h3><a name="path-appends"><code><font size="4"> path</font></code> appends</a>
  1165. [path.append]</h3>
  1166. <p>The append operations use <code>
  1167. operator/=</code> to denote their semantic effect of appending <i>
  1168. preferred-separator</i> when needed. </p>
  1169. <pre>path&amp; operator/=(const path&amp; p);</pre>
  1170. <blockquote>
  1171. <p><i>Effects:</i></p>
  1172. <blockquote>
  1173. <p>Appends <code>path::preferred_separator</code> to <code>pathname</code>,
  1174. converting format and encoding if required ([<a href="#path.arg.convert">path.arg.convert</a>]), unless:</p>
  1175. <ul>
  1176. <li>
  1177. <p>an added separator
  1178. would be redundant, or</li>
  1179. <li>
  1180. <p>would change a relative path to an absolute path, or</li>
  1181. <li>
  1182. <p><code>p.empty()</code>, or</li>
  1183. <li>
  1184. <p><code>*p.native().cbegin()</code> is a directory separator.</li>
  1185. </ul>
  1186. <p>Then appends <code>p.native()</code> to <code>pathname</code>.</p>
  1187. </blockquote>
  1188. <p><i>Returns: </i><code>*this</code></p>
  1189. </blockquote>
  1190. <pre>template &lt;class <a href="#Source">Source</a>&gt;
  1191. path&amp; operator/=(Source const &amp; source);
  1192. template &lt;class <a href="#Source">Source</a>&gt;
  1193. path&amp; append(Source const &amp; source, const codecvt_type&amp; cvt);
  1194. template &lt;class <a href="#InputIterator">InputIterator</a>&gt;
  1195. path&amp; append(InputIterator begin, InputIterator end, const codecvt_type&amp; cvt=codecvt());</pre>
  1196. <blockquote>
  1197. <p><i>Effects:</i></p>
  1198. <blockquote>
  1199. <p>Appends <code>path::preferred_separator</code> to <code>pathname</code>, converting
  1200. format and encoding if required ([<a href="#path.arg.convert">path.arg.convert</a>]), unless:</p>
  1201. <ul>
  1202. <li>
  1203. <p>an added separator
  1204. would be redundant, or</li>
  1205. <li>
  1206. <p>would change a relative path to an absolute path, or</li>
  1207. <li>
  1208. <p><code>p.empty()</code>, or</li>
  1209. <li>
  1210. <p><code>*p.native().cbegin()</code> is a separator.</li>
  1211. </ul>
  1212. <p>Appends the contents [<code>begin</code>,<code>end</code>)
  1213. or <code>source</code> to <code>pathname</code>, converting format and
  1214. encoding if required ([<a href="#path.arg.convert">path.arg.convert</a>]).</p>
  1215. </blockquote>
  1216. <p><i>Returns: </i><code>*this</code></p>
  1217. </blockquote>
  1218. <h3><a name="path-concatenation"><code>path</code> concatenation</a> [path.concat]</h3>
  1219. <pre>path&amp; operator+=(const path&amp; x);
  1220. path&amp; operator+=(const string_type&amp; x);
  1221. path&amp; operator+=(const value_type* x);
  1222. path&amp; operator+=(value_type x);
  1223. template &lt;class Source&gt;
  1224. path&amp; operator+=(Source const&amp; x);
  1225. template &lt;class CharT&gt;
  1226. path&amp; operator+=(CharT x);
  1227. template &lt;class InputIterator&gt;
  1228. path&amp; concat(InputIterator begin, InputIterator end);
  1229. template &lt;class InputIterator&gt;
  1230. path&amp; concat(InputIterator begin, InputIterator end, const codecvt_type&amp; cvt);</pre>
  1231. <blockquote><p><i>Postcondition:</i> <code>native() == prior_native + <i>effective-argument</i></code>,
  1232. where <code>prior_native</code> is <code>native()</code> prior to the call to <code>operator+=</code>,
  1233. and <code><i>effective-argument</i></code> is:</p>
  1234. <ul><li>
  1235. <p><code>x.native()</code> if <code>x</code> is present and is <code>const path&amp;</code>, otherwise</li>
  1236. <li>
  1237. <p><code>s</code>, where <code>s</code> is
  1238. <code>std::basic_string&lt;typename std::iterator_traits&lt;InputIterator&gt;::value_type&gt;<br>s(begin, end)</code>,
  1239. if <code>begin</code> and <code>end</code> arguments are present, otherwise</li>
  1240. <li>
  1241. <p><code>x</code>.</li></ul><p>If the value type of <code><i>effective-argument</i></code> would not be <code>path::value_type</code>, the actual argument or argument range is first
  1242. converted so that <code><i>effective-argument</i></code> has value type <code>path::value_type</code>.</li> </p>
  1243. <p><i>Returns: </i><code>*this</code></p>
  1244. </blockquote>
  1245. <h3><a name="path-modifiers"> <code>
  1246. path</code> modifiers</a> [path.modifiers]</h3>
  1247. <pre>void <a name="path-clear">clear</a>();</pre>
  1248. <blockquote>
  1249. <p><i>Postcondition:</i> <code>this-&gt;empty()</code> is true.</p>
  1250. </blockquote>
  1251. <pre>path&amp; <a name="path-make_preferred">make_preferred</a>();</pre>
  1252. <blockquote>
  1253. <p><i>Effects:</i> <i>directory-separator</i>s are converted to <i>preferred-separator</i>s.
  1254. See [<a href="#Operating-system-examples">fs.os.examples</a>].</p>
  1255. <p><i>Returns:</i> <code>*this</code></p>
  1256. </blockquote>
  1257. <pre>path&amp; <a name="path-remove_filename">remove_filename</a>();</pre>
  1258. <blockquote>
  1259. <p><i>Returns: </i>As if, <code>*this = parent_path();</code></p>
  1260. <p>[<i>Note:</i> This function is needed to efficiently implement <code>directory_iterator</code>. It is exposed to allow additional uses. The actual
  1261. implementation may be much more efficient than <code>*this = parent_path()</code>&nbsp; <i>—end
  1262. note</i>]</p>
  1263. </blockquote>
  1264. <pre>path&amp; <a name="path-replace_extension">replace_extension</a>(const path&amp; new_extension = path());</pre>
  1265. <blockquote>
  1266. <p><i>Effects:</i></p>
  1267. <ul>
  1268. <li>
  1269. <p>Any existing <code>extension()</code> is removed from the stored path,
  1270. then</li>
  1271. <li>
  1272. <p>iff
  1273. <code>new_extension</code> is not empty and does not begin with a dot
  1274. character, a dot character is appended to the stored path, then</li>
  1275. <li>
  1276. <p>
  1277. <code>new_extension</code> is appended to the stored path.</li>
  1278. </ul>
  1279. <p><i>Returns:</i> <code>*this</code></p>
  1280. </blockquote>
  1281. <pre><code>void <a name="path-swap">swap</a>(path&amp; rhs) noexcept;</code></pre>
  1282. <blockquote>
  1283. <p><i>Effects:</i> Swaps the contents of the two paths.</p>
  1284. <p><i>Complexity: </i>constant time.</p>
  1285. </blockquote>
  1286. <h3><a name="path-lexical-operations"><code>path</code> lexical operations</a>
  1287. [path.lex.ops]</h3>
  1288. <pre>path <a name="lexically_normal">lexically_normal</a>() const;</pre>
  1289. <blockquote>
  1290. <p><i>Overview:</i> Returns <code>*this</code> with redundant current directory
  1291. (<i>dot</i>), parent directory (<i>dot-dot</i>), and <i>directory-separator</i> elements removed.</p>
  1292. <p><i>Returns:</i> <code>*this</code> in <a href="#normal-form">normal form</a>.</p>
  1293. <p><i>Remarks:</i> Uses <code>operator/=</code> to compose the returned path.</p>
  1294. <p>[<i>Example:</i></p>
  1295. <p><code>assert(path(&quot;foo/./bar/..&quot;).lexically_normal() == &quot;foo&quot;);<br>
  1296. assert(path(&quot;foo/.///bar/../&quot;).lexically_normal() == &quot;foo/.&quot;);</code></p>
  1297. <p>The above assertions will succeed.<i> </i>On Windows, the
  1298. returned path&#39;s <i>directory-separator</i> characters will be backslashes rather than slashes, but that
  1299. does not affect <code>path</code> equality.<i> —end example</i>]</p>
  1300. </blockquote>
  1301. <pre>path <a name="lexically_relative">lexically_relative</a>(const path&amp; base) const;</pre>
  1302. <blockquote>
  1303. <p><i>Overview:</i> Returns <code>*this</code> made relative to <code>base</code>.
  1304. Treats empty or identical paths as corner cases, not errors. Does not resolve
  1305. symlinks. Does not first normalize <code>*this</code> or <code>base</code>.</p>
  1306. <p><i>Remarks:</i> Uses <code>std::mismatch(begin(), end(), base.begin(), base.end())</code>, to determine the first mismatched element of
  1307. <code>*this</code> and <code>base</code>. Uses <code>operator==</code> to
  1308. determine if elements match. </p>
  1309. <p><i>Returns:</i> </p>
  1310. <ul>
  1311. <li>
  1312. <code>path()</code> if the first mismatched element of <code>*this</code> is equal to <code>
  1313. begin()</code> or the first mismatched element
  1314. of <code>base</code> is equal to <code>base.begin()</code>, or<br>&nbsp;
  1315. </li>
  1316. <li>
  1317. <code>path(&quot;.&quot;)</code> if the first mismatched element of <code>
  1318. *this</code> is equal to <code>
  1319. end()</code> and the first mismatched element
  1320. of <code>base</code> is equal to <code>base.end()</code>, or<br>&nbsp;
  1321. </li>
  1322. <li>An object of class <code>path</code> composed via application of <code>
  1323. operator/= path(&quot;..&quot;)</code> for each element in the half-open
  1324. range [first
  1325. mismatched element of <code>base</code>, <code>base.end()</code>), and then
  1326. application of <code>operator/=</code> for each element in the half-open
  1327. range
  1328. [first mismatched element of <code>*this</code>, <code>end()</code>).
  1329. </li>
  1330. </ul>
  1331. <p>[<i>Example:</i></p>
  1332. <p><code>assert(path(&quot;/a/d&quot;).lexically_relative(&quot;/a/b/c&quot;) == &quot;../../d&quot;);<br>
  1333. assert(path(&quot;/a/b/c&quot;).lexically_relative(&quot;/a/d&quot;) == &quot;../b/c&quot;);<br>
  1334. assert(path(&quot;a/b/c&quot;).lexically_relative(&quot;a&quot;) == &quot;b/c&quot;);<br>
  1335. assert(path(&quot;a/b/c&quot;).lexically_relative(&quot;a/b/c/x/y&quot;) == &quot;../..&quot;);<br>
  1336. assert(path(&quot;a/b/c&quot;).lexically_relative(&quot;a/b/c&quot;) == &quot;.&quot;);<br>
  1337. assert(path(&quot;a/b&quot;).lexically_relative(&quot;c/d&quot;) == &quot;&quot;);</code></p>
  1338. <p>The above assertions will succeed.<i> </i>On Windows, the
  1339. returned path&#39;s <i>directory-separator</i>s will be backslashes rather than
  1340. forward slashes, but that
  1341. does not affect <code>path</code> equality.<i> —end example</i>]</p>
  1342. <p>[<i>Note:</i> If symlink following semantics are desired, use the operational function <code>
  1343. <a href="#op-relative">relative</a></code>&nbsp; <i>—end note</i>]</p>
  1344. <p>[<i>Note:</i> If <a href="#lexically_normal">normalization</a> is needed to ensure
  1345. consistent matching of elements, apply <code><a href="#lexically_normal">lexically_normal()</a></code>
  1346. to <code>*this</code>, <code>base</code>, or both. <i>—end note</i>]</p>
  1347. <pre>path <a name="lexically_proximate">lexically_proximate</a>(const path&amp; base) const;</pre>
  1348. <blockquote>
  1349. <p><i>Returns:</i> If <code>lexically_relative(base)</code> returns a non-empty path, returns that path.
  1350. Otherwise returns <code>*this</code>.</p>
  1351. <p>[<i>Note:</i> If symlink following semantics are desired, use the operational function <code>
  1352. <a href="#op-relative">relative</a></code>&nbsp; <i>—end note</i>]</p>
  1353. <p>[<i>Note:</i> If <a href="#lexically_normal">normalization</a> is needed to ensure
  1354. consistent matching of elements, apply <code><a href="#lexically_normal">lexically_normal()</a></code>
  1355. to <code>*this</code>, <code>base</code>, or both. <i>—end note</i>]</p>
  1356. </blockquote>
  1357. <h3> <a name="path-native-format-observers"><code><font size="4">path</font></code> native format observers</a>
  1358. [path.native.obs]</h3>
  1359. <p>The string returned by all native format observers is in the <a href="#native-pathname-format">native pathname format</a>.</p>
  1360. <pre>const string_type&amp; <a name="native">native</a>() const noexcept;</pre>
  1361. <blockquote>
  1362. <p><i>Returns:</i> <code>pathname</code>.</p>
  1363. </blockquote>
  1364. <pre>const value_type* <a name="c_str">c_str</a>() const noexcept;</pre>
  1365. <blockquote>
  1366. <p><i>Returns:</i> <code>pathname.c_str()</code>.</p>
  1367. </blockquote>
  1368. <pre>string_type::size_type <a name="path-size">size</a>() const noexcept;</pre>
  1369. <blockquote>
  1370. <p><i>Returns:</i> <code>pathname.size()</code>.</p>
  1371. </blockquote>
  1372. <pre>template &lt;class String&gt;
  1373. String <a name="string-template">string</a>(const codecvt_type&amp; cvt=codecvt()) const;</pre>
  1374. <blockquote>
  1375. <p><i>Returns:</i> <code>pathname</code>.</p>
  1376. <p><i>Remarks:</i> If <code>string_type</code> is a different type than <code>String</code>, conversion is performed by <code>cvt</code>.</p>
  1377. </blockquote>
  1378. <pre>string <a name="string">string</a>(const codecvt_type&amp; cvt=codecvt()) const;
  1379. wstring <a name="wstring">wstring</a>(const codecvt_type&amp; cvt=codecvt()) const;
  1380. u16string <a name="u16string">u16string</a>() const;
  1381. u32wstring <a name="u32wstring">u32wstring</a>() const; </pre>
  1382. <blockquote>
  1383. <p><i>Returns:</i> <code>pathname</code>.</p>
  1384. <p><i>Remarks:</i> If <code>string_type</code> is a different type than
  1385. function's return type, conversion is performed by <code>cvt</code>.</p>
  1386. </blockquote>
  1387. <h3> <a name="path-generic-format-observers"><code><font size="4">path</font></code> generic format observers</a>
  1388. [path.generic.obs]</h3>
  1389. <p>The string returned by all generic format observers is in the <a href="#generic-pathname-format">generic pathname format</a>.</p>
  1390. <pre>template &lt;class String&gt;
  1391. String <a name="generic_string-template">generic_string</a>(const codecvt_type&amp; cvt=codecvt()) const;</pre>
  1392. <blockquote>
  1393. <p><i>Returns:</i> <code>pathname</code>.</p>
  1394. <p><i>Remarks:</i> If <code>string_type</code> is a different type than <code>String</code>, conversion is performed by <code>cvt</code>.</p>
  1395. </blockquote>
  1396. <pre>string <a name="generic_string">generic_string</a>(const codecvt_type&amp; cvt=codecvt()) const;
  1397. wstring <a name="generic_wstring">generic_wstring</a>(const codecvt_type&amp; cvt=codecvt()) const;
  1398. u16string <a name="generic_u16string">generic_u16string</a>() const;
  1399. u32wstring <a name="generic_u32wstring">generic_u32wstring</a>() const; </pre>
  1400. <blockquote>
  1401. <p><i>Returns:</i> <code>pathname</code>.</p>
  1402. <p><i>Remarks:</i>&nbsp; If <code>string_type</code> is a different type than
  1403. function's return type, conversion is performed by <code>cvt</code>.</p>
  1404. </blockquote>
  1405. <h3> <a name="path-compare"><code>path</code> compare</a> [path.compare]</h3>
  1406. <pre>int compare(const path&amp; p) const noexcept;</pre>
  1407. <blockquote>
  1408. <p><i>Returns:</i> A value less than 0 if the elements of <code>*this</code> are lexicographically less than the elements of <code>p</code>, otherwise a
  1409. value greater than 0 if the elements of <code>*this</code> are
  1410. lexicographically greater than the elements of <code>p</code>, otherwise 0.</p>
  1411. <p>Remark: The elements are determined as if by iteration over the half-open
  1412. range [<code>begin()</code>, <code>end()</code>) for <code>*this</code> and&nbsp; <code>p</code>.</p>
  1413. </blockquote>
  1414. <pre>int compare(const std::string&amp; s) const</pre>
  1415. <blockquote>
  1416. <p><i>Returns:</i> <code>compare(path(s))</code>.</p>
  1417. </blockquote>
  1418. <pre>int compare(const value_type* s) const</pre>
  1419. <blockquote>
  1420. <p><i>Returns:</i> <code>compare(path(s))</code>.</p>
  1421. </blockquote>
  1422. <h3> <a name="path-decomposition"> <code><font size="4">path</font></code> decomposition</a>
  1423. [path.decompose]</h3>
  1424. <p><span style="background-color: #E0E0E0"><i>See the <a href="#path-decomposition-table">Path decomposition table</a> for examples
  1425. for values returned by decomposition functions. The <a href="tutorial.html#Using-path-decomposition">Tutorial</a> may also be
  1426. helpful.</i></span></p>
  1427. <pre>path <a name="path-root_name">root_name</a>() const;</pre>
  1428. <blockquote>
  1429. <p><i>Returns:</i> <i>root-name,</i> if <code>pathname</code> includes <i>root-name</i>, otherwise <code>path()</code>. </p>
  1430. </blockquote>
  1431. <pre>path <a name="path-root_directory">root_directory</a>() const;</pre>
  1432. <blockquote>
  1433. <p><i>Returns:</i> <i>root-directory</i>, if <code>pathname</code> includes <i>root-directory</i>, otherwise <code>path()</code>.</p>
  1434. <p>If <i>root-directory</i> is composed of <i>slash name</i>, <i>slash</i> is
  1435. excluded from the returned string.</p>
  1436. </blockquote>
  1437. <pre>path <a name="path-root_path">root_path</a>() const;</pre>
  1438. <blockquote>
  1439. <p><i>Returns:</i> <code>root_name() / root_directory()</code></p>
  1440. </blockquote>
  1441. <pre>path <a name="path-relative_path">relative_path</a>() const;</pre>
  1442. <blockquote>
  1443. <p><i>Returns:</i> A <code>path</code> composed from <code>pathname</code>, if <code>!empty()</code>, beginning
  1444. with the first <i>filename</i> after <i>root-path</i>. Otherwise, <code>path()</code>.</p>
  1445. </blockquote>
  1446. <pre>path <a name="path-parent_path">parent_path</a>() const;</pre>
  1447. <blockquote>
  1448. <p><i>Returns:</i> <code>(empty() || begin() == —end()) ? path() : <i>pp</i></code>, where <code><i>pp</i></code> is constructed as if by
  1449. starting with an empty <code>path</code> and successively applying <code>operator/=</code> for each element in the range <code>begin()</code>, <code>—end()</code>.</p>
  1450. <p>[<i>Example:</i></p>
  1451. <blockquote>
  1452. <pre>std::cout &lt;&lt; path(&quot;/foo/bar.txt&quot;).parent_path(); // outputs &quot;/foo&quot;
  1453. std::cout &lt;&lt; path(&quot;/foo/bar&quot;).parent_path(); // outputs &quot;/foo&quot;
  1454. std::cout &lt;&lt; path(&quot;/foo/bar/&quot;).parent_path(); // outputs &quot;/foo/bar&quot;
  1455. std::cout &lt;&lt; path(&quot;/&quot;).parent_path(); // outputs &quot;&quot;
  1456. std::cout &lt;&lt; path(&quot;.&quot;).parent_path(); // outputs &quot;&quot;
  1457. std::cout &lt;&lt; path(&quot;..&quot;).parent_path(); // outputs &quot;&quot;</pre>
  1458. </blockquote>
  1459. <p> See the last bullet item in the <a href="#path-iterators">
  1460. forward traversal order</a> list for why the <code>&quot;/foo/bar/&quot;</code> example
  1461. doesn&#39;t output <code>&quot;/foo&quot;</code>.</p>
  1462. <p> <i>—end example</i>]</p>
  1463. </blockquote>
  1464. <pre>path <a name="path-filename">filename</a>() const;</pre>
  1465. <blockquote>
  1466. <p><i>Returns:</i> <code>empty() ? path() : *—end()</code></p>
  1467. <p>[<i>Example:</i></p>
  1468. <blockquote>
  1469. <pre>std::cout &lt;&lt; path(&quot;/foo/bar.txt&quot;).filename(); // outputs &quot;bar.txt&quot;
  1470. std::cout &lt;&lt; path(&quot;/foo/bar&quot;).filename(); // outputs &quot;bar&quot;
  1471. std::cout &lt;&lt; path(&quot;/foo/bar/&quot;).filename(); // outputs &quot;.&quot;
  1472. std::cout &lt;&lt; path(&quot;/&quot;).filename(); // outputs &quot;/&quot;
  1473. std::cout &lt;&lt; path(&quot;.&quot;).filename(); // outputs &quot;.&quot;
  1474. std::cout &lt;&lt; path(&quot;..&quot;).filename(); // outputs &quot;..&quot;</pre>
  1475. </blockquote>
  1476. <p> See the last bullet item in the <a href="#path-iterators">
  1477. forward traversal order</a> list for why the <code>&quot;/foo/bar/&quot;</code> example
  1478. doesn&#39;t output <code>&quot;bar&quot;</code>.</p>
  1479. <p> <i>—end example</i>]</p>
  1480. </blockquote>
  1481. <pre>path <a name="path-stem">stem</a>() const;</pre>
  1482. <blockquote>
  1483. <p><i>Returns:</i> if <code>p.filename()</code> contains a dot but does not
  1484. consist solely of one or to two dots, returns
  1485. the substring of <code>p.filename()</code> starting at its beginning and
  1486. ending at the last dot (the dot is not included). Otherwise,
  1487. returns <code>p.filename()</code>.</p>
  1488. <p>[<i>Example:</i></p>
  1489. <blockquote>
  1490. <pre><code>std::cout &lt;&lt; path(&quot;/foo/bar.txt&quot;).stem();</code> // outputs &quot;<code>bar</code>&quot;
  1491. path p = &quot;foo.bar.baz.tar&quot;;
  1492. for (; !p.extension().empty(); p = p.stem())
  1493. std::cout &lt;&lt; p.extension() &lt;&lt; '\n';
  1494. // outputs: .tar
  1495. // .baz
  1496. // .bar</pre>
  1497. </blockquote>
  1498. <p> <i>—end example</i>]</p>
  1499. </blockquote>
  1500. <pre>path <a name="path-extension">extension</a>() const;</pre>
  1501. <blockquote>
  1502. <p><i>Returns:</i> if <code>p.filename()</code> contains a dot but does not
  1503. consist solely of one or to two dots, returns
  1504. the substring of <code>p.filename()</code> starting at the rightmost dot
  1505. and ending at the path's end. Otherwise, returns an empty <code>path</code> object. </p>
  1506. <p><i>Remarks:</i> Implementations are permitted but not required to define additional
  1507. behavior for file systems which append additional elements to extensions, such
  1508. as alternate data streams or partitioned dataset names.</p>
  1509. <p>[<i>Example:</i></p>
  1510. <blockquote>
  1511. <pre><code>std::cout &lt;&lt; path(&quot;/foo/bar.txt&quot;).extension(); //</code> outputs &quot;<code>.txt</code>&quot;</pre>
  1512. </blockquote>
  1513. <p> <i>—end example</i>]</p>
  1514. <p>[<i>Note:<b> </b></i>The dot is included in the return value so that it is
  1515. possible to distinguish between no extension and an empty extension.
  1516. See <a href="http://permalink.gmane.org/gmane.comp.lib.boost.devel/199744">
  1517. http://permalink.gmane.org/gmane.comp.lib.boost.devel/199744</a> for more
  1518. extensive rationale.&nbsp; <i>—end note</i>]</p>
  1519. </blockquote>
  1520. <h3> <a name="path-query"> <code><font size="4">path</font></code> query</a> [path.query]</h3>
  1521. <pre>bool <a name="path-empty">empty</a>() const;</pre>
  1522. <blockquote>
  1523. <p><i>Returns:</i> <code>m_pathname.empty()</code>.</p>
  1524. </blockquote>
  1525. <pre>bool <a name="filename_is_dot">filename_is_dot</a>() const;</pre>
  1526. <blockquote>
  1527. <p><i>Returns:</i> <code>filename() == path(&quot;.&quot;)</code></p>
  1528. <p>[<i>Example:</i></p>
  1529. <blockquote>
  1530. <pre>std::cout &lt;&lt; path(&quot;.&quot;).filename_is_dot(); // outputs 1
  1531. std::cout &lt;&lt; path(&quot;/.&quot;).filename_is_dot(); // outputs 1
  1532. std::cout &lt;&lt; path(&quot;foo/.&quot;).filename_is_dot(); // outputs 1
  1533. std::cout &lt;&lt; path(&quot;foo/&quot;).filename_is_dot(); // outputs 1
  1534. std::cout &lt;&lt; path(&quot;/&quot;).filename_is_dot(); // outputs 0
  1535. std::cout &lt;&lt; path(&quot;/foo&quot;).filename_is_dot(); // outputs 0
  1536. std::cout &lt;&lt; path(&quot;/foo.&quot;).filename_is_dot(); // outputs 0
  1537. std::cout &lt;&lt; path(&quot;..&quot;).filename_is_dot(); // outputs 0</pre>
  1538. </blockquote>
  1539. <p> See the last bullet item in the <a href="#path-iterators">forward traversal order</a>
  1540. list for why <code>path(&quot;foo/&quot;).filename()</code> is a dot filename.</p>
  1541. <p> <i>—end example</i>]</p>
  1542. </blockquote>
  1543. <pre>bool <a name="filename_is_dot_dot">filename_is_dot_dot</a>() const;</pre>
  1544. <blockquote>
  1545. <p><i>Returns:</i> <code>filename() == path(&quot;..&quot;)</code></p>
  1546. </blockquote>
  1547. <pre>bool <a name="path-has_root_path">has_root_path</a>() const;</pre>
  1548. <blockquote>
  1549. <p><i>Returns:</i> <code>!<a href="#path-root_path">root_path</a>().empty()</code></p>
  1550. </blockquote>
  1551. <pre>bool <a name="path-has_root_name">has_root_name</a>() const;</pre>
  1552. <blockquote>
  1553. <p><i>Returns:</i> <code>!<a href="#path-root_name">root_name</a>().empty()</code></p>
  1554. </blockquote>
  1555. <pre>bool <a name="path-has_root_directory">has_root_directory</a>() const;</pre>
  1556. <blockquote>
  1557. <p><i>Returns:</i> <code>!<a href="#path-root_directory">root_directory</a>().empty()</code></p>
  1558. </blockquote>
  1559. <pre>bool <a name="path-has_relative_path">has_relative_path</a>() const;</pre>
  1560. <blockquote>
  1561. <p><i>Returns:</i> <code>!<a href="#path-has_relative_path">relative_path</a>().empty()</code></p>
  1562. </blockquote>
  1563. <pre>bool <a name="path-has_parent_path">has_parent_path</a>() const;</pre>
  1564. <blockquote>
  1565. <p><i>Returns:</i> <code>!<a href="#path-parent_path">parent_path</a>().empty()</code></p>
  1566. </blockquote>
  1567. <pre>bool <a name="path-has_filename">has_filename</a>() const;</pre>
  1568. <blockquote>
  1569. <p><i>Returns:</i> <code>!<a href="#path-filename">filename</a>().empty()</code></p>
  1570. </blockquote>
  1571. <pre>bool <a name="path-has_stem">has_stem</a>() const;</pre>
  1572. <blockquote>
  1573. <p><i>Returns:</i> <code>!<a href="#path-stem">stem</a>().empty()</code></p>
  1574. </blockquote>
  1575. <pre>bool <a name="path-has_extension">has_extension</a>() const;</pre>
  1576. <blockquote>
  1577. <p><i>Returns:</i> <code>!<a href="#path-has_extension">extension</a>().empty()</code></p>
  1578. </blockquote>
  1579. <pre>bool <a name="path-is_absolute">is_absolute</a>() const;</pre>
  1580. <blockquote>
  1581. <p><i>Returns:</i> <code>true</code> if the elements of <code>root_path()</code> uniquely identify a directory, else <code>false</code>.</p>
  1582. </blockquote>
  1583. <pre>bool <a name="path-is_relative">is_relative</a>() const;</pre>
  1584. <blockquote>
  1585. <p><i>Returns:</i> <code>!is_absolute()</code>.</p>
  1586. </blockquote>
  1587. <h3> <a name="path-iterators"> <code>
  1588. <font size="4">path</font></code> iterators</a> [path.itr]</h3>
  1589. <p> Path iterators <code>iterator</code>, <code>const_iterator</code>,
  1590. <code>reverse_iterator</code>, and <code>const_reverse_iterator</code> iterate over the elements of the stored pathname.</p>
  1591. <p> Path iterators are constant iterators satisfying
  1592. the requirements of a bidirectional iterator (C++ Std, 24.1.4 Bidirectional
  1593. iterators [lib.bidirectional.iterators]). The <code>value_type</code>&nbsp; of
  1594. an iterator is <code>path</code>.</p>
  1595. <blockquote>
  1596. <p> [<i>Note:</i> Path iterators store their value objects internally
  1597. and when dereferenced return references to those internal objects. They cannot
  1598. be used with iterator adaptors such as <code>std::reverse_iterator</code> that
  1599. assume references obtained by dereferencing an iterator point to objects that
  1600. out-live the iterator itself. <i>—end note</i>] </p>
  1601. </blockquote>
  1602. <p>Calling any non-const member function of a <code>path</code> object
  1603. invalidates all iterators referring to elements of that object.</p>
  1604. <p> The forward traversal order is as follows:</p>
  1605. <ul>
  1606. <li>The <i>root-name</i> element, if present.</li>
  1607. <li>The <i>root-directory</i> element, if present, in the generic format. <i>
  1608. [note:</i> the generic format is required to ensure lexicographical
  1609. comparison works correctly. <i>—end note</i>]</li>
  1610. <li>Each successive <i>filename</i> element, if present.</li>
  1611. <li><i>Dot</i>, if one or more trailing non-root <i>slash</i>
  1612. characters are present.|</li>
  1613. </ul>
  1614. <blockquote>
  1615. <p>[<i>Note:</i> Treating the last element during iteration as <i>dot</i> when
  1616. there is a trailing directory separator enables lexical (i.e. syntactic)
  1617. distinction between paths to directories versus paths to regular files. Such a
  1618. distinction is usually irrelevant on POSIX and Windows based operating
  1619. systems, but may be a requirement on other operating systems. <i>—end note</i>]</p>
  1620. </blockquote>
  1621. <p>The backward traversal order is the reverse of forward traversal.</p>
  1622. <pre>iterator begin() const;</pre>
  1623. <blockquote>
  1624. <p><i>Returns:</i> An iterator for the first element in forward traversal
  1625. order. If no elements are present, the end iterator.</p>
  1626. </blockquote>
  1627. <pre>iterator end() const;</pre>
  1628. <blockquote>
  1629. <p><i>Returns:</i> The end iterator.</p>
  1630. </blockquote>
  1631. <pre>reverse_iterator rbegin() const;</pre>
  1632. <blockquote>
  1633. <p><i>Returns:</i> An iterator for the first element in backward traversal
  1634. order. If no elements are present, the end iterator.</p>
  1635. </blockquote>
  1636. <pre>reverse_iterator rend() const;</pre>
  1637. <blockquote>
  1638. <p><i>Returns:</i> The end iterator.</p>
  1639. </blockquote>
  1640. <h3><a name="path-imbued-locale"><code><font size="4"> path</font></code>
  1641. imbued locale</a> [path.imbued.locale]</h3>
  1642. <p><code>path</code> operations sometimes require encoding conversions between
  1643. <code>pathname</code> and some other string object where one of the value types
  1644. is <code>char</code> and the other is <code>wchar_t</code>. Such conversions
  1645. shall be performed by the <code>path::codecvt()</code> facet.</p>
  1646. <blockquote>
  1647. <p><span style="background-color: #FFFF00">[</span><i><span style="background-color: #FFFF00">Example:</span></i><span style="background-color: #FFFF00">
  1648. ... </span><i><span style="background-color: #FFFF00">—end example</span></i><span style="background-color: #FFFF00">]</span></p>
  1649. </blockquote>
  1650. <pre>static std::locale <a name="path-imbue">imbue</a>(const std::locale&amp; loc);</pre>
  1651. <blockquote>
  1652. <p><i>Effects:</i> Stores a copy of <code>loc</code> as the imbued <code>path</code>
  1653. locale.</p>
  1654. <p><i>Returns:</i> The previous imbued <code>path</code> locale.</p>
  1655. <p><i>Remarks:</i> The initial value of the imbued <code>path</code> locale is
  1656. operating system dependent. It shall be a locale with a <code>codecvt</code>
  1657. facet for a <code>char</code> string encoding appropriate for the operating
  1658. system. See ([<a href="#Operating-system-examples">fs.os.examples</a>]).&nbsp; </p>
  1659. </blockquote>
  1660. <pre>static const codecvt_type&amp; <a name="path-codecvt">codecvt</a>();</pre>
  1661. <blockquote>
  1662. <p><i>Returns:</i> The <code>codecvt</code> facet for the imbued<code> path</code>
  1663. locale .</p>
  1664. </blockquote>
  1665. <h3> <a name="path-deprecated-functions"><code><font size="4"> path</font></code> deprecated functions</a></h3>
  1666. <p> Several member functions from previous versions of <code>class path</code> have been deprecated, either because they have been renamed or because the
  1667. functionality is no longer desirable or has become obsolete.</p>
  1668. <p> Deprecated functions available by default; will be suppressed if <code>BOOST_FILESYSTEM_NO_DEPRECATED</code> is defined:</p>
  1669. <blockquote>
  1670. <pre>path&amp; remove_leaf() { return remove_filename(); }
  1671. path leaf() const { return filename(); }
  1672. path branch_path() const { return parent_path(); }
  1673. bool has_leaf() const { return !m_path.empty(); }
  1674. bool has_branch_path() const { return !parent_path().empty(); }</pre>
  1675. </blockquote>
  1676. <p> Deprecated functions not available by default; will be supplied if <code>BOOST_FILESYSTEM_DEPRECATED</code> is defined:</p>
  1677. <blockquote>
  1678. <pre>const std::string file_string() const { return native_string(); }
  1679. const std::string directory_string() const { return native_string(); }
  1680. const std::string native_file_string() const { return native_string(); }
  1681. const std::string native_directory_string() const { return native_string(); }
  1682. const string_type external_file_string() const { return native(); }
  1683. const string_type external_directory_string() const { return native(); }</pre>
  1684. </blockquote>
  1685. <h3> <a name="path-non-member-functions"> <code><font size="4">path</font></code> non-member functions</a>
  1686. [path.non-member]</h3>
  1687. <pre>bool lexicographical_compare(path::iterator first1, path::iterator last1,
  1688. path::iterator first2, path::iterator last2);</pre>
  1689. <blockquote>
  1690. <p><i>Returns:</i> <code>true</code> if the sequence of <code>native()</code> strings for the elements defined by the half-open range <code>[first1,last1)</code> is
  1691. lexicographically less than the sequence of <code>native()</code> strings for
  1692. the elements defined by the half-open range <code>[first2,last2)</code>. Returns <code>false</code> otherwise.</p>
  1693. <p><i>Remarks:</i> If two sequences have the same number of elements and their
  1694. corresponding elements are equivalent, then neither sequence is
  1695. lexicographically less than the other. If one sequence is a prefix of the
  1696. other, then the shorter sequence is lexicographically less than the longer
  1697. sequence. Otherwise, the lexicographical comparison of the sequences yields
  1698. the same result as the comparison of the first corresponding pair of elements
  1699. that are not equivalent.</p>
  1700. <p>[<i>Note:</i> A <code>path</code> aware <code>lexicographical_compare</code> algorithm is provided for historical reasons. <i>—end note</i>]</p>
  1701. </blockquote>
  1702. <div>
  1703. <pre>path <a name="lex-normal">lexically_normal</a>(const path&amp; p);</pre>
  1704. </div>
  1705. <blockquote>
  1706. <p><i>Overview:</i> Returns <code>p</code> with redundant current
  1707. directory (<i>dot</i>), parent directory (<i>dot-dot</i>), and <i>
  1708. directory-separator</i> elements removed.</p>
  1709. <p><i>Returns:</i> <code>p</code> in
  1710. <a href="#normal-form">
  1711. normal form</a>.</p>
  1712. <p><i>Remarks:</i> Uses <code>operator/=</code> to compose the
  1713. returned path.</p>
  1714. <p>[<i>Example:</i></p>
  1715. <p><code>assert(lexically_normal(&quot;foo/./bar/..&quot;) == &quot;foo&quot;);<br>
  1716. assert(lexically_normal(&quot;foo/.///bar/../&quot;) == &quot;foo/.&quot;);</code></p>
  1717. <p>All of the above assertions will succeed.<i> </i>On Windows, the
  1718. returned path&#39;s <i>directory-separator</i> characters will be backslashes
  1719. rather than slashes, but that does not affect <code>path</code> equality.<i>
  1720. —end example</i>]</p>
  1721. </blockquote>
  1722. <div>
  1723. <pre>path lexically_<a name="lex-relative">relative</a>(const path&amp; p, const path&amp; base);</pre>
  1724. </div>
  1725. <blockquote>
  1726. <p><i>Overview:</i> Returns <code>p</code> made relative to <code>
  1727. base</code>. Treats empty or identical paths as corner cases, not errors. Does
  1728. not resolve symlinks. Does not first normalize <code>p</code> or <code>base</code>.</p>
  1729. <p><i>Remarks:</i> Uses <code>std::mismatch(p.begin(), p.end(),
  1730. base.begin(), base.end())</code>, to determine the first mismatched element of
  1731. <code>p</code> and <code>base</code>. Uses <code>operator==</code> to
  1732. determine if elements match. </p>
  1733. <p><i>Returns:</i> </p>
  1734. <ul>
  1735. <li>
  1736. <p><code>path()</code> if the first mismatched element of <code>p</code>
  1737. is equal to <code>p.begin()</code> or the first mismatched element of <code>
  1738. base</code> is equal to <code>base.begin()</code>, or<br>
  1739. &nbsp; </li>
  1740. <li>
  1741. <p><code>path(&quot;.&quot;)</code> if the first mismatched element of <code>
  1742. p</code> is equal to <code>p.end()</code> and the first mismatched element
  1743. of <code>base</code> is equal to <code>base.end()</code>, or<br>
  1744. &nbsp; </li>
  1745. <li>
  1746. <p>An object of class <code>path</code> composed via application
  1747. of <code>operator/= path(&quot;..&quot;)</code> for each element in the half-open
  1748. range [first mismatched element of <code>base</code>, <code>base.end()</code>),
  1749. and then application of <code>operator/=</code> for each element in the
  1750. half-open range [first mismatched element of <code>p</code>, <code>p.end()</code>).
  1751. </li>
  1752. </ul>
  1753. <p>[<i>Example:</i></p>
  1754. <p><code>assert(lexically_relative(&quot;/a/d&quot;, &quot;/a/b/c&quot;) == &quot;../../d&quot;);<br>
  1755. assert(lexically_relative(&quot;/a/b/c&quot;, &quot;/a/d&quot;) == &quot;../b/c&quot;);<br>
  1756. assert(lexically_relative(&quot;a/b/c&quot;, &quot;a&quot;) == &quot;b/c&quot;);<br>
  1757. assert(lexically_relative(&quot;a/b/c&quot;, &quot;a/b/c/x/y&quot;) == &quot;../..&quot;);<br>
  1758. assert(lexically_relative(&quot;a/b/c&quot;, &quot;a/b/c&quot;) == &quot;.&quot;);<br>
  1759. assert(lexically_relative(&quot;a/b&quot;, &quot;c/d&quot;) == &quot;&quot;);</code></p>
  1760. <p>All of the above assertions will succeed.<i> </i>On Windows, the
  1761. returned path&#39;s <i>directory-separator</i>s will be backslashes rather than
  1762. forward slashes, but that does not affect <code>path</code> equality.<i> —end
  1763. example</i>]</p>
  1764. <p>[<i>Note:</i> If symlink following semantics are desired, use the
  1765. operational function <code>
  1766. <a href="#op-relative">
  1767. relative</a></code>&nbsp; <i>—end note</i>]</p>
  1768. <p>[<i>Note:</i> If <a href="#normal-form">normalization</a> is needed to ensure consistent matching of elements, wrap
  1769. <code>p</code>, <code>base</code>, or both in calls <code>
  1770. <a href="#lex-normal">
  1771. lexically_normal()</a></code>. <i>—end note</i>]</p>
  1772. </blockquote>
  1773. <pre>void swap( path&amp; lhs, path&amp; rhs )</pre>
  1774. <blockquote>
  1775. <p><i>Effects: </i><code>lhs.swap(rhs)</code>.</p>
  1776. </blockquote>
  1777. <pre>std::size_t <a name="hash_value">hash_value</a> (const path&amp; p);</pre>
  1778. <blockquote>
  1779. <p><i>Returns:</i> A hash value for the path <code>p</code>. If
  1780. for two paths, <code>p1 == p2</code> then <code>hash_value(p1) == hash_value(p2)</code>.</p>
  1781. <p>This allows paths to be used with <a href="../../functional/hash/index.html">Boost.Hash</a>.</p>
  1782. </blockquote>
  1783. <pre>bool operator&lt; (const path&amp; lhs, const path&amp; rhs);</pre>
  1784. <blockquote>
  1785. <p><i>Returns:</i> <code>return lhs.compare(rhs.begin) &lt; 0</code>.</p>
  1786. </blockquote>
  1787. <pre>bool operator&lt;=(const path&amp; lhs, const path&amp; rhs);</pre>
  1788. <blockquote>
  1789. <p><i>Returns:</i> <code>!(rhs &lt; lhs)</code>.</p>
  1790. </blockquote>
  1791. <pre>bool operator&gt; (const path&amp; lhs, const path&amp; rhs);</pre>
  1792. <blockquote>
  1793. <p><i>Returns:</i> <code>rhs &lt; lhs</code>.</p>
  1794. </blockquote>
  1795. <pre>bool operator&gt;=(const path&amp; lhs, const path&amp; rhs);</pre>
  1796. <blockquote>
  1797. <p><i>Returns:</i> <code>!(lhs &lt; rhs)</code>.</p>
  1798. </blockquote>
  1799. <pre>bool operator==(const path&amp; lhs, const path&amp; rhs);</pre>
  1800. <blockquote>
  1801. <p><i>Returns:</i> <code>!(lhs &lt; rhs) &amp;&amp; !(rhs &lt; lhs)</code>.</p>
  1802. <p>[<i>Note:</i> <a name="Path-equality">Path equality</a> and path
  1803. equivalence have different semantics.</p>
  1804. <p>Equality is determined by the <code>path</code> non-member <code>operator==</code>, which considers the two path's lexical
  1805. representations only. Thus <code>path(&quot;foo&quot;) == &quot;bar&quot;</code> is never <code>true</code>.</p>
  1806. <p>Equivalence is determined by the <a href="#equivalent"><code>equivalent()</code></a> non-member function, which determines if two paths <a href="#path">resolve</a> to the same file system entity.
  1807. Thus <code>equivalent(&quot;foo&quot;, &quot;bar&quot;)</code> will be <code>true</code> when both paths resolve to the same file.</p>
  1808. <p>Programmers wishing to determine if two paths are &quot;the same&quot; must decide if
  1809. &quot;the same&quot; means &quot;the same representation&quot; or &quot;resolve to the same actual
  1810. file&quot;, and choose the appropriate function accordingly. <i>—end note</i>]</p>
  1811. </blockquote>
  1812. <pre>bool operator!=(const path&amp; lhs, const path&amp; rhs);</pre>
  1813. <blockquote>
  1814. <p><i>Returns:</i> <code>!(lhs == rhs)</code>.</p>
  1815. </blockquote>
  1816. <pre>path operator/ (const path&amp; lhs, const path&amp; rhs);</pre>
  1817. <blockquote>
  1818. <p><i>Returns:</i> <code>path(lhs) /= rhs</code>.</p>
  1819. </blockquote>
  1820. <h3> <a name="path-non-member-operators"><code><font size="4">path</font></code></a><a name="path-inserter-extractor"> inserter
  1821. and extractor</a> [path.io]</h3>
  1822. <p> The inserter and extractor delimit the string with double-quotes (<code>&quot;</code>)
  1823. so that paths with embedded spaces will round trip correctly. Ampersand (<code>&amp;</code>)
  1824. is as an escape character, so the path can itself contain double quotes.</p>
  1825. <pre>template &lt;class Char, class Traits&gt;
  1826. std::basic_ostream&lt;Char, Traits&gt;&amp; operator&lt;&lt;(std::basic_ostream&lt;Char, Traits&gt;&amp; os,
  1827. const path&amp; p)
  1828. </pre>
  1829. <blockquote>
  1830. <p><i>Effects: </i>Insert characters into <code>os</code>:</p>
  1831. <ul>
  1832. <li>
  1833. <p>A double-quote.</p>
  1834. </li>
  1835. <li>
  1836. <p>Each character in <code>p.string&lt;std::basic_string&lt;Char&gt;&gt;()</code>.
  1837. If the character to be inserted is equal to the escape character or a
  1838. double-quote, as determined by <code>operator==</code>, first insert the
  1839. escape character.</p>
  1840. </li>
  1841. <li>
  1842. <p>A double-quote.</p>
  1843. </li>
  1844. </ul>
  1845. <p><i>Returns:</i> <code>os</code></p>
  1846. </blockquote>
  1847. <pre>template &lt;class Char, class Traits&gt;
  1848. inline std::basic_istream&lt;Char, Traits&gt;&amp; operator&gt;&gt;(std::basic_istream&lt;Char, Traits&gt;&amp; is,
  1849. path&amp; p)
  1850. </pre>
  1851. <blockquote>
  1852. <p><i>Effects:&nbsp; </i><code>&nbsp;std::basic_string&lt;Char&gt; str;<br>
  1853. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; is &gt;&gt; <a href="../../io/doc/quoted_manip.html">boost::io::quoted</a>(str, static_cast&lt;Char&gt;('&amp;'));<br>
  1854. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p = str;</code></p>
  1855. <p><i>Effects:&nbsp; </i>Extract characters from os:</p>
  1856. <ul>
  1857. <li>If the first character that would be extracted is equal to double-quote,
  1858. as determined by <code>operator==</code>, then:<ul>
  1859. <li>Discard the initial double-quote.</li>
  1860. <li>Save the value and then turn off the <code>skipws</code> flag.</li>
  1861. <li><code>p.clear()</code></li>
  1862. <li>Until an unescaped double-quote character is reached or <code>
  1863. is.not_good()</code>, extract characters from <code>os</code> and append
  1864. them to <code>p</code>, except that if an escape character is reached,
  1865. ignore it and append the next character to <code>p</code>.</li>
  1866. <li>Discard the final double-quote character.</li>
  1867. <li>Restore the <code>skipws</code> flag to its original value.</li>
  1868. </ul>
  1869. </li>
  1870. <li>Otherwise, <code>os &gt;&gt; p</code>.</li>
  1871. </ul>
  1872. <p><i>Returns:</i> <code>is</code></p>
  1873. </blockquote>
  1874. <h2><a name="Class-filesystem_error">Class <code>filesystem_error</code>
  1875. [class.filesystem_error]</a></h2>
  1876. <pre>namespace boost
  1877. {
  1878. namespace filesystem
  1879. {
  1880. class filesystem_error : public system_error
  1881. {
  1882. public:
  1883. filesystem_error();
  1884. filesystem_error(const filesystem_error&amp;);
  1885. <a href="#filesystem_error-2-arg">filesystem_error</a>(const std::string&amp; what_arg,
  1886. system::error_code ec);
  1887. <a href="#filesystem_error-3-arg">filesystem_error</a>(const std::string&amp; what_arg,
  1888. const path&amp; p1, system::error_code ec);
  1889. <a href="#filesystem_error-4-arg">filesystem_error</a>(const std::string&amp; what_arg,
  1890. const path&amp; p1, const path&amp; p2, system::error_code ec);
  1891. filesystem_error&amp; filesystem_error(const filesystem_error&amp;);
  1892. ~filesystem_error();
  1893. filesystem_error&amp; operator=(const filesystem_error&amp;);
  1894. const path&amp; <a href="#filesystem_error-path1">path1</a>() const;
  1895. const path&amp; <a href="#filesystem_error-path2">path2</a>() const;
  1896. const char * <a href="#filesystem_error-what">what</a>() const;
  1897. };
  1898. } // namespace filesystem
  1899. } // namespace boost</pre>
  1900. <p>The class template <code>filesystem_error</code> defines the type of
  1901. objects thrown as exceptions to report file system errors from functions described in this
  1902. reference documentation.</p>
  1903. <h3> <a name="filesystem_error-members"> <code>filesystem_error</code> members</a>
  1904. [filesystem_error.members]</h3>
  1905. <pre><a name="filesystem_error-2-arg">filesystem_error</a>(const std::string&amp; what_arg, error_code ec);</pre>
  1906. <blockquote>
  1907. <p><i>Postcondition:</i></p>
  1908. <table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="46%">
  1909. <tr>
  1910. <td width="18%"><b>Expression</b></td>
  1911. <td width="82%"><b>Value</b></td>
  1912. </tr>
  1913. <tr>
  1914. <td width="18%" bgcolor="#FFFFFF"><code>
  1915. runtime_error::what()</code></td>
  1916. <td width="82%" bgcolor="#FFFFFF">
  1917. <code><i>what_arg</i>.c_str()</code></td>
  1918. </tr>
  1919. <tr>
  1920. <td width="18%"><code>code()</code></td>
  1921. <td width="82%"><code>ec</code></td>
  1922. </tr>
  1923. <tr>
  1924. <td width="18%"><code>path1().empty()</code></td>
  1925. <td width="82%"><code>true</code></td>
  1926. </tr>
  1927. <tr>
  1928. <td width="18%"><code>path2().empty()</code></td>
  1929. <td width="82%"><code>true</code></td>
  1930. </tr>
  1931. </table>
  1932. </blockquote>
  1933. <pre><a name="filesystem_error-3-arg">filesystem_error</a>(const std::string&amp; what_arg, const path&amp; p1, error_code ec);</pre>
  1934. <blockquote>
  1935. <p><i>Postcondition:</i></p>
  1936. <table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="46%">
  1937. <tr>
  1938. <td width="18%"><b>Expression</b></td>
  1939. <td width="82%"><b>Value</b></td>
  1940. </tr>
  1941. <tr>
  1942. <td width="18%" valign="top"><code>
  1943. runtime_error::what()</code></td>
  1944. <td width="82%">
  1945. <code><i>what_arg</i>.c_str()</code></td>
  1946. </tr>
  1947. <tr>
  1948. <td width="18%" valign="top"><code>code()</code></td>
  1949. <td width="82%"><code>ec</code></td>
  1950. </tr>
  1951. <tr>
  1952. <td width="18%" valign="top"><code>path1()</code></td>
  1953. <td width="82%">Reference to stored copy of <code>p1</code></td>
  1954. </tr>
  1955. <tr>
  1956. <td width="18%" valign="top"><code>path2().empty()</code></td>
  1957. <td width="82%"><code>true</code></td>
  1958. </tr>
  1959. </table>
  1960. </blockquote>
  1961. <pre><a name="filesystem_error-4-arg">filesystem_error</a>(const std::string&amp; what_arg, const path&amp; p1, const path&amp; p2, error_code ec);</pre>
  1962. <blockquote>
  1963. <p><i>Postcondition:</i></p>
  1964. <table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="46%">
  1965. <tr>
  1966. <td width="18%"><b>Expression</b></td>
  1967. <td width="82%"><b>Value</b></td>
  1968. </tr>
  1969. <tr>
  1970. <td width="18%"><code>
  1971. runtime_error::what()</code></td>
  1972. <td width="82%">
  1973. <u>
  1974. <code><i>w</i></code></u><code><i>hat_arg</i>.c_str()</code></td>
  1975. </tr>
  1976. <tr>
  1977. <td width="18%"><code>code()</code></td>
  1978. <td width="82%"><code>ec</code></td>
  1979. </tr>
  1980. <tr>
  1981. <td width="18%"><code>path1()</code></td>
  1982. <td width="82%">Reference to stored copy of <code>p1</code></td>
  1983. </tr>
  1984. <tr>
  1985. <td width="18%"><code>path2()</code></td>
  1986. <td width="82%">Reference to stored copy of <code>p2</code></td>
  1987. </tr>
  1988. </table>
  1989. </blockquote>
  1990. <pre>const path&amp; <a name="filesystem_error-path1">path1</a>() const;</pre>
  1991. <blockquote>
  1992. <p><i>Returns:</i> Reference to copy of <code>p1</code> stored by the
  1993. constructor, or, if none, an empty path.</p>
  1994. </blockquote>
  1995. <pre>const path&amp; <a name="filesystem_error-path2">path2</a>() const;</pre>
  1996. <blockquote>
  1997. <p><i>Returns:</i> Reference to copy of <code>p2</code> stored by the
  1998. constructor, or, if none, an empty path.</p>
  1999. </blockquote>
  2000. <pre>const char* <a name="filesystem_error-what">what</a>() const;</pre>
  2001. <blockquote>
  2002. <p><i>Returns: </i>A string containing <code>runtime_error::what()</code>. The exact format is unspecified.
  2003. Implementations are encouraged but not required to include <code>path1.native_string()</code>if not empty, <code>path2.native_string()</code>if
  2004. not empty, and <code>system_error::what()</code> strings in the returned
  2005. string.</p>
  2006. </blockquote>
  2007. <h2><a name="Enum-file_type">Enum file_type</a> [enum.file_type]</h2>
  2008. <p>This enum specifies constants uses to identify file types.</p>
  2009. <table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111">
  2010. <tr>
  2011. <td><b>Constant Name</b></td>
  2012. <td><b>Meaning</b></td>
  2013. </tr>
  2014. <tr>
  2015. <td><code>status_error</code></td>
  2016. <td>An error occurred while trying to obtain the status of the file. The
  2017. file simply not being found is <b><u>not</u></b> considered a status error. </td>
  2018. </tr>
  2019. <tr>
  2020. <td><code>file_not_found</code></td>
  2021. <td>The file could not be found</td>
  2022. </tr>
  2023. <tr>
  2024. <td><code>regular_file</code></td>
  2025. <td>Regular file</td>
  2026. </tr>
  2027. <tr>
  2028. <td><code>directory_file</code></td>
  2029. <td>Directory file</td>
  2030. </tr>
  2031. <tr>
  2032. <td><code>symlink_file</code></td>
  2033. <td>Symbolic link file</td>
  2034. </tr>
  2035. <tr>
  2036. <td><code>block_file</code></td>
  2037. <td>Block special file</td>
  2038. </tr>
  2039. <tr>
  2040. <td><code>character_file</code></td>
  2041. <td>Character special file</td>
  2042. </tr>
  2043. <tr>
  2044. <td><code>fifo_file</code></td>
  2045. <td>FIFO or pipe file</td>
  2046. </tr>
  2047. <tr>
  2048. <td><code>socket_file</code></td>
  2049. <td>Socket file</td>
  2050. </tr>
  2051. <tr>
  2052. <td><code>type_unknown</code></td>
  2053. <td>The file exists, but it is of a system specific type not covered by any
  2054. of the above cases.</td>
  2055. </tr>
  2056. </table>
  2057. <h2><a name="Enum-perms">Enum perms</a> [enum.perms]</h2>
  2058. <p>This <code>enum</code> specifies bitmask constants uses to identify file
  2059. permissions. <i><span style="background-color: #E0E0E0">ISO/</span><span style="background-color: #E0E0E0">IEC</span><span style="background-color: #E0E0E0"> 9945
  2060. (POSIX) specifies actual values, and those values have been adopted here because
  2061. they are very familiar and ingrained for many POSIX
  2062. users.</span></i></p>
  2063. <blockquote>
  2064. <p><span style="background-color: #FFFF00">Windows: All permissions except write are currently ignored. There is only a
  2065. single write permission; setting write permission for owner, group, or others
  2066. sets write permission for all, and removing write permission for owner, group,
  2067. or others removes write permission for all. </span> </p>
  2068. </blockquote>
  2069. <table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111">
  2070. <tr>
  2071. <td><b>Name</b></td>
  2072. <td align="center"><b>Value<br>
  2073. (octal)</b></td>
  2074. <td align="center"><b>ISO/IEC 9945<br>
  2075. macro</b></td>
  2076. <td><b>Definition or notes</b></td>
  2077. </tr>
  2078. <tr><td>
  2079. <p><code>no_perms</code></td><td><code>0</code></td><td></td>
  2080. <td>There are no permissions set for the file. Note: <code>file_not_found</code> is <code>no_perms</code> rather than <code>perms_not_known</code></td>
  2081. </tr>
  2082. <tr><td><code>owner_read</code></td><td><code>0400</code></td><td> <code>S_IRUSR</code></td>
  2083. <td> Read permission, owner</td>
  2084. </tr>
  2085. <tr><td><code>owner_write</code></td><td><code>0200</code></td><td> <code>S_IWUSR</code></td>
  2086. <td> Write permission, owner</td>
  2087. </tr>
  2088. <tr><td><code>owner_exe</code></td><td><code>0100</code></td><td> <code>S_IXUSR</code></td>
  2089. <td> Execute/search permission, owner</td>
  2090. </tr>
  2091. <tr><td><code>owner_all</code></td><td><code>0700</code></td><td> <code>S_IRWXU</code></td>
  2092. <td> Read, write, execute/search by owner; <code>owner_read | owner_write | owner_exe</code></td>
  2093. </tr>
  2094. <tr><td><code>group_read</code></td><td><code>040</code></td><td> <code>S_IRGRP</code></td>
  2095. <td> Read permission, group</td>
  2096. </tr>
  2097. <tr><td><code>group_write</code></td><td><code>020</code></td><td> <code>S_IWGRP</code></td>
  2098. <td> Write permission, group</td>
  2099. </tr>
  2100. <tr><td><code>group_exe</code></td><td><code>010</code></td><td> <code>S_IXGRP</code></td>
  2101. <td> Execute/search permission, group</td>
  2102. </tr>
  2103. <tr><td><code>group_all</code></td><td><code>070</code></td><td> <code>S_IRWXG</code></td>
  2104. <td> Read, write, execute/search by group; <code>group_read | group_write | group_exe</code></td>
  2105. </tr>
  2106. <tr><td><code>others_read</code></td><td><code>04</code></td><td> <code>S_IROTH</code></td>
  2107. <td> Read permission, others</td>
  2108. </tr>
  2109. <tr><td><code>others_write</code></td><td><code>02</code></td><td> <code>S_IWOTH</code></td>
  2110. <td> Write permission, others</td>
  2111. </tr>
  2112. <tr><td><code>others_exe</code></td><td><code>01</code></td><td> <code>S_IXOTH</code></td>
  2113. <td> Execute/search permission, others</td>
  2114. </tr>
  2115. <tr><td><code>others_all</code></td><td><code>07</code></td><td> <code>S_IRWXO</code></td>
  2116. <td>Read, write, execute/search by others; <code>others_read | others_write | others_exe</code></td>
  2117. </tr>
  2118. <tr><td><code>all_all</code></td><td><code>0777</code></td><td> </td><td><code>owner_all | group_all | others_all</code></td>
  2119. </tr>
  2120. <tr><td><code>set_uid_on_exe</code></td><td><code>04000</code></td><td> <code>S_ISUID</code></td>
  2121. <td> Set-user-ID on execution</td>
  2122. </tr>
  2123. <tr><td><code>set_gid_on_exe</code></td><td><code>02000</code></td><td> <code>S_ISGID</code></td>
  2124. <td> Set-group-ID on execution</td>
  2125. </tr>
  2126. <tr><td><code><a name="sticky_bit">sticky_bit</a> </code></td><td><code>01000</code></td><td> <code>S_ISVTX</code></td>
  2127. <td> Operating system dependent. Inherently non-portable, even between ISO/IEC 9945
  2128. operating systems.</td>
  2129. </tr>
  2130. <tr><td><code><a name="perms_mask">perms_mask</a></code></td><td><code>07777</code></td><td> &nbsp;</td>
  2131. <td><code>all_all | set_uid_on_exe | set_gid_on_exe | sticky_bit</code></td>
  2132. </tr>
  2133. <tr><td><code>perms_not_known</code></td><td><code>0xFFFF</code></td><td></td><td>
  2134. The permissions are not known, such as when a <code>file_status</code> object
  2135. is created without specifying the permissions</td>
  2136. </tr>
  2137. <tr><td>
  2138. <p><code>add_perms</code></td><td><code>0x1000</code></td><td></td><td>
  2139. <p><code>permissions()</code> adds the argument permission bits to the
  2140. file's current bits</td>
  2141. </tr>
  2142. <tr><td><code>remove_perms</code></td><td><code>0x2000</code></td><td></td><td>
  2143. <code>permissions()</code> removes the argument permission bits from the
  2144. file's current bits</td>
  2145. </tr>
  2146. <tr><td><code><a name="symlink_perms">symlink_perms</a></code></td><td><code>0x4000</code></td><td></td><td>
  2147. <span style="background-color: #FFFF00">On ISO/</span><span style="background-color: #FFFF00">IEC</span><span style="background-color: #FFFF00"> 9945
  2148. </span> <code><span style="background-color: #FFFF00">permissions()</span></code><span style="background-color: #FFFF00"> resolves symlinks unless
  2149. </span> <code><span style="background-color: #FFFF00">symlink_perms</span></code><span style="background-color: #FFFF00"> is specified.
  2150. Meaningless on Windows as </span> <code>
  2151. <span style="background-color: #FFFF00">permissions()</span></code><span style="background-color: #FFFF00"> never resolves symlinks.
  2152. Meaningless on Mac OS X and some other BSD systems as </span> <code>
  2153. <span style="background-color: #FFFF00">permissions()</span></code><span style="background-color: #FFFF00"> always resolves symlinks. Get over it.</span></td>
  2154. </tr>
  2155. </table>
  2156. <h2><a name="file_status">Class file_status</a> [class.file_status]</h2>
  2157. <pre>namespace boost
  2158. {
  2159. namespace filesystem
  2160. {
  2161. class file_status
  2162. {
  2163. public:
  2164. // <a href="#file_status-constructors">constructors</a>
  2165. file_status() noexcept;
  2166. explicit file_status(<a href="#file_type">file_type</a> ft, <a href="#Enum-perms">perms</a> prms = perms_not_known) noexcept;
  2167. // compiler generated
  2168. file_status(const file_status&amp;) noexcept;
  2169. file_status&amp; operator=(const file_status&amp;) noexcept;
  2170. ~file_status() noexcept;
  2171. // <a href="#file_status-observers">observers</a>
  2172. <a href="#file_type">file_type</a> type() const noexcept;
  2173. <a href="#Enum-perms">perms</a> permissions() const noexcept;
  2174. // <a href="#file_status-modifiers">modifiers</a>
  2175. void type(<a href="#file_type">file_type</a> ft) noexcept;
  2176. void permissions(<a href="#Enum-perms">perms</a> prms) noexcept;
  2177. };
  2178. } // namespace filesystem
  2179. } // namespace boost</pre>
  2180. <p>An object of type <code>file_status</code> stores information about the type
  2181. and permissions of a file.</p>
  2182. <h3><a name="file_status-constructors"><code>file_status</code> constructors</a>
  2183. [file_status.cons]</h3>
  2184. <pre>explicit file_status() noexcept;</pre>
  2185. <blockquote>
  2186. <p><i>Postconditions:</i> <code>type() == status_error</code>, <code>permissions() == perms_not_known</code>.</p>
  2187. </blockquote>
  2188. <pre>explicit file_status(<a href="#file_type">file_type</a> ft, <a href="#Enum-perms">perms</a> prms = perms_not_known) noexcept;</pre>
  2189. <blockquote>
  2190. <p><i>Postconditions:</i> <code>type() == ft</code>, <code>permissions() == prms</code>.</p>
  2191. </blockquote>
  2192. <h3><a name="file_status-observers"><code>file_status</code> observers</a> [file_status.obs]</h3>
  2193. <pre><a href="#file_type">file_type</a> type() const noexcept;</pre>
  2194. <blockquote>
  2195. <p><i>Returns: </i>The value of <code>type()</code> specified by the <i>postconditions</i> of the most recent call to a constructor, operator=, or <code>type(file_type)</code> function.</p>
  2196. </blockquote>
  2197. <pre><a href="#Enum-perms">perms</a> permissions() const noexcept;</pre>
  2198. <blockquote>
  2199. <p><i>Returns: </i>The value of <code>permissions()</code> specified by the <i>postconditions</i> of the most recent call to a constructor, operator=, or <code>permissions(perms)</code> function.</p>
  2200. </blockquote>
  2201. <h3><a name="file_status-modifiers"><code>file_status</code> modifiers</a> [file_status.mods]</h3>
  2202. <pre>void type(<a href="#file_type">file_type</a> ft) noexcept;</pre>
  2203. <blockquote>
  2204. <p><i>Postconditions:</i> <code>type() == ft</code>.</p>
  2205. </blockquote>
  2206. <pre>void permissions(<a href="#Enum-perms">perms</a> prms) noexcept;</pre>
  2207. <blockquote>
  2208. <p><i>Postconditions:</i> <code>permissions() == prms</code>.</p>
  2209. </blockquote>
  2210. <h2><a name="Class-directory_entry">Class <code>directory_entry</code></a> [class.directory_entry]</h2>
  2211. <pre>namespace boost
  2212. {
  2213. namespace filesystem
  2214. {
  2215. class directory_entry
  2216. {
  2217. public:
  2218. // <a href="#directory_entry-constructors">constructors</a> and destructor
  2219. directory_entry();
  2220. directory_entry(const directory_entry&amp;);
  2221. explicit directory_entry(const path&amp; p, file_status st=file_status(),
  2222. file_status symlink_st=file_status());
  2223. ~directory_entry();
  2224. // <a href="#directory_entry-modifiers">modifiers</a>
  2225. directory_entry&amp; operator=(const directory_entry&amp;);
  2226. void assign(const path&amp; p, file_status st=file_status(),
  2227. file_status symlink_st=file_status());
  2228. void replace_filename(const path&amp; p, file_status st=file_status(),
  2229. file_status symlink_st=file_status());
  2230. // <a href="#directory_entry-observers">observers</a>
  2231. const path&amp; path() const;
  2232. file_status status() const;
  2233. file_status status(system::error_code&amp; ec) const;
  2234. file_status symlink_status() const;
  2235. file_status symlink_status(system::error_code&amp; ec) const;
  2236. bool operator&lt; (const directory_entry&amp; rhs);
  2237. bool operator==(const directory_entry&amp; rhs);
  2238. bool operator!=(const directory_entry&amp; rhs);
  2239. bool operator&lt; (const directory_entry&amp; rhs);
  2240. bool operator&lt;=(const directory_entry&amp; rhs);
  2241. bool operator&gt; (const directory_entry&amp; rhs);
  2242. bool operator&gt;=(const directory_entry&amp; rhs);
  2243. private:
  2244. path m_path; // for exposition only
  2245. mutable file_status m_status; // for exposition only; stat()-like
  2246. mutable file_status m_symlink_status; // for exposition only; lstat()-like
  2247. };
  2248. } // namespace filesystem
  2249. } // namespace boost</pre>
  2250. <p>A <code>directory_entry</code> object stores a <code>path object</code>,
  2251. a <code>file_status</code> object for non-symbolic link status, and a <code>file_status</code> object for symbolic link status. The <code>file_status</code> objects act as value caches.</p>
  2252. <blockquote>
  2253. <p>[<i>Note:</i> Because <code>status()</code>on a pathname may be a relatively expensive operation,
  2254. some operating systems provide status information as a byproduct of directory
  2255. iteration. Caching such status information can result is significant time savings. Cached and
  2256. non-cached results may differ in the presence of file system races. <i>—end note</i>]</p>
  2257. <p><span style="background-color: #E0E0E0"><i>Actual cold-boot timing of iteration over
  2258. a directory with 15,047 entries was six seconds for non-cached status queries
  2259. versus one second for cached status queries. Windows XP, 3.0 GHz processor, with
  2260. a moderately fast hard-drive. Similar speedups are expected on Linux and BSD-derived
  2261. systems that provide status as a by-product of directory iteration.</i></span></p>
  2262. </blockquote>
  2263. <h3> <a name="directory_entry-constructors"> <code>directory_entry </code>constructors</a>
  2264. [directory_entry.cons]</h3>
  2265. <pre>directory_entry();</pre>
  2266. <blockquote>
  2267. <p><i>Postcondition:</i></p>
  2268. <table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="36%">
  2269. <tr>
  2270. <td width="18%"><b>Expression</b></td>
  2271. <td width="82%"><b>Value</b></td>
  2272. </tr>
  2273. <tr>
  2274. <td width="18%"><code>path().empty()</code></td>
  2275. <td width="82%"><code>true</code></td>
  2276. </tr>
  2277. <tr>
  2278. <td width="18%"><code>status()</code></td>
  2279. <td width="82%"><code>file_status()</code></td>
  2280. </tr>
  2281. <tr>
  2282. <td width="18%"><code>symlink_status()</code></td>
  2283. <td width="82%"><code>file_status()</code></td>
  2284. </tr>
  2285. </table>
  2286. </blockquote>
  2287. <pre>explicit directory_entry(const path&amp; p, file_status st=file_status(), file_status symlink_st=file_status());</pre>
  2288. <blockquote>
  2289. <p><i>Postcondition:</i></p>
  2290. <table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="36%">
  2291. <tr>
  2292. <td width="18%"><b>Expression</b></td>
  2293. <td width="82%"><b>Value</b></td>
  2294. </tr>
  2295. <tr>
  2296. <td width="18%"><code>path()</code></td>
  2297. <td width="82%"><code>p</code></td>
  2298. </tr>
  2299. <tr>
  2300. <td width="18%"><code>status()</code></td>
  2301. <td width="82%"><code>st</code></td>
  2302. </tr>
  2303. <tr>
  2304. <td width="18%"><code>symlink_status()</code></td>
  2305. <td width="82%"><code>symlink_st</code></td>
  2306. </tr>
  2307. </table>
  2308. </blockquote>
  2309. <h3> <a name="directory_entry-modifiers"> <code>directory_entry </code>modifiers</a>
  2310. [directory_entry.mods]</h3>
  2311. <pre>void assign(const path&amp; p, file_status st=file_status(), file_status symlink_st=file_status());</pre>
  2312. <blockquote>
  2313. <p><i>Postcondition:</i></p>
  2314. <table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="36%">
  2315. <tr>
  2316. <td width="18%"><b>Expression</b></td>
  2317. <td width="82%"><b>Value</b></td>
  2318. </tr>
  2319. <tr>
  2320. <td width="18%"><code>path()</code></td>
  2321. <td width="82%"><code>p</code></td>
  2322. </tr>
  2323. <tr>
  2324. <td width="18%"><code>status()</code></td>
  2325. <td width="82%"><code>st</code></td>
  2326. </tr>
  2327. <tr>
  2328. <td width="18%"><code>symlink_status()</code></td>
  2329. <td width="82%"><code>symlink_st</code></td>
  2330. </tr>
  2331. </table>
  2332. </blockquote>
  2333. <pre>void replace_filename(const path&amp; p, file_status st=file_status(), file_status symlink_st=file_status());</pre>
  2334. <blockquote>
  2335. <p><i>Postcondition:</i></p>
  2336. <table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="43%">
  2337. <tr>
  2338. <td width="18%"><b>Expression</b></td>
  2339. <td width="82%"><b>Value</b></td>
  2340. </tr>
  2341. <tr>
  2342. <td width="18%"><code>path()</code></td>
  2343. <td width="82%"><code>path().branch() / s</code></td>
  2344. </tr>
  2345. <tr>
  2346. <td width="18%"><code>status()</code></td>
  2347. <td width="82%"><code>st</code></td>
  2348. </tr>
  2349. <tr>
  2350. <td width="18%"><code>symlink_status()</code></td>
  2351. <td width="82%"><code>symlink_st</code></td>
  2352. </tr>
  2353. </table>
  2354. </blockquote>
  2355. <h3> <a name="directory_entry-observers"> <code>directory_entry</code> observers</a>
  2356. [directory_entry.obs]</h3>
  2357. <pre>const path&amp; path() const;</pre>
  2358. <blockquote>
  2359. <p><i>Returns:</i> <code>m_path</code></p>
  2360. </blockquote>
  2361. <pre>file_status status() const;
  2362. file_status status(system::error_code&amp; ec) const;</pre>
  2363. <blockquote>
  2364. <p><i>Effects:</i> As if,</p>
  2365. <blockquote>
  2366. <pre>if ( !status_known( m_status ) )
  2367. {
  2368. if ( status_known(m_symlink_status) &amp;&amp; !is_symlink(m_symlink_status) )
  2369. { m_status = m_symlink_status; }
  2370. else { m_status = status(m_path<i>[, ec]</i>); }
  2371. }</pre>
  2372. </blockquote>
  2373. <p><i>Returns:</i> <code>m_status</code></p>
  2374. <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
  2375. </blockquote>
  2376. <pre>file_status symlink_status() const;
  2377. file_status symlink_status(system::error_code&amp; ec) const;</pre>
  2378. <blockquote>
  2379. <p>
  2380. <i>Effects:</i> As if,</p>
  2381. <blockquote>
  2382. <pre>if ( !status_known( m_symlink_status ) )
  2383. {
  2384. m_symlink_status = symlink_status(m_path<i>[, ec]</i>);
  2385. }</pre>
  2386. </blockquote>
  2387. <p><i>Returns:</i> <code>m_symlink_status</code></p>
  2388. <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
  2389. </blockquote>
  2390. <pre>bool operator==(const directory_entry&amp; rhs);</pre>
  2391. <blockquote>
  2392. <p><i>Returns:</i> <code>m_path == rhs.m_path</code>.</p>
  2393. </blockquote>
  2394. <pre>bool operator!=(const directory_entry&amp; rhs);</pre>
  2395. <blockquote>
  2396. <p><i>Returns:</i> <code>m_path != rhs.m_path</code>.</p>
  2397. </blockquote>
  2398. <pre>bool operator&lt; (const directory_entry&amp; rhs);</pre>
  2399. <blockquote>
  2400. <p><i>Returns:</i> <code>m_path &lt; rhs.m_path</code>.</p>
  2401. </blockquote>
  2402. <pre>bool operator&lt;=(const directory_entry&amp; rhs);</pre>
  2403. <blockquote>
  2404. <p><i>Returns:</i> <code>m_path &lt;= rhs.m_path</code>.</p>
  2405. </blockquote>
  2406. <pre>bool operator&gt; (const directory_entry&amp; rhs);</pre>
  2407. <blockquote>
  2408. <p><i>Returns:</i> <code>m_path &gt; rhs.m_path</code>.</p>
  2409. </blockquote>
  2410. <pre>bool operator&gt;=(const directory_entry&amp; rhs);</pre>
  2411. <blockquote>
  2412. <p><i>Returns:</i> <code>m_path &gt;= rhs.m_path</code>.</p>
  2413. </blockquote>
  2414. <h2><a name="Class-directory_iterator">Class <code>directory_iterator</code>
  2415. [class.directory_iterator]</a></h2>
  2416. <p>Objects of type <code>directory_iterator</code> provide standard library
  2417. compliant iteration over the contents of a directory. Also see class <code><a href="#Class-recursive_directory_iterator">recursive_directory_iterator</a></code>.</p>
  2418. <pre>namespace boost
  2419. {
  2420. namespace filesystem
  2421. {
  2422. class directory_iterator
  2423. {
  2424. public:
  2425. // <a href="#directory_iterator-members">member functions</a>
  2426. directory_iterator() noexcept; // creates the &quot;end&quot; iterator
  2427. directory_iterator(const directory_iterator&amp;);
  2428. explicit directory_iterator(const path&amp; p, <a href="#directory_options">directory_options</a> opts = directory_options::none);
  2429. directory_iterator(const path&amp; p, system::error_code&amp; ec);
  2430. directory_iterator(const path&amp; p, <a href="#directory_options">directory_options</a> opts, system::error_code&amp; ec);
  2431. ~directory_iterator();
  2432. directory_iterator&amp; operator=(const directory_iterator&amp;);
  2433. directory_iterator&amp; operator++();
  2434. directory_iterator&amp; increment(system::error_code&amp; ec);
  2435. // other members as required by
  2436. // C++ Std, 24.1.1 Input iterators [input.iterators]
  2437. };
  2438. } // namespace filesystem
  2439. } // namespace boost</pre>
  2440. <p> <code>directory_iterator</code> satisfies the requirements of an
  2441. input iterator (C++ Std, 24.2.1, Input iterators [input.iterators]).</p>
  2442. <p>A <code>directory_iterator</code> reads successive elements from the directory for
  2443. which it was constructed, as if by calling ISO/IEC 9945 <code><a href="http://www.opengroup.org/onlinepubs/000095399/functions/readdir_r.html">readdir() or readdir_r()</a></code>. After a <code>directory_iterator</code> is constructed, and every time <code>operator++</code> is called,
  2444. it reads a directory element and stores information about it in an object of type <code><a href="#Class-directory_entry">directory_entry</a></code>. <code>operator++</code> is not equality preserving; that is, <code>i == j</code> does not imply that <code>++i == ++j</code>. </p>
  2445. <blockquote>
  2446. <p>[<i>Note:</i> The practical consequence of not preserving equality is that directory iterators
  2447. can only be used for single-pass algorithms. <i>—end note</i>]</p>
  2448. </blockquote>
  2449. <p>If the end of the directory elements is reached, the iterator shall become equal to
  2450. the end iterator value. The constructor <code>directory_iterator()</code> with no arguments always constructs an end iterator object, which
  2451. shall be the only valid iterator for the end condition. The result of <code>operator*</code> on an end iterator is not defined. For any other iterator value
  2452. a <code>const directory_entry&amp;</code> is returned. The result of <code>operator-&gt;</code> on an end iterator is
  2453. undefined behavior. For any other iterator value a <code>const directory_entry*</code> is
  2454. returned. </p>
  2455. <p>Two end iterators are always equal. An end iterator shall not be equal to a non-end
  2456. iterator.</p>
  2457. <blockquote>
  2458. <p><i><span style="background-color: #E0E0E0">The above wording is based on the
  2459. Standard Library's istream_iterator wording.</span></i></p>
  2460. </blockquote>
  2461. <p>The result of calling the <code>path()</code> member of the <code>directory_entry</code> object obtained by dereferencing a <code>directory_iterator</code> is a reference to a <code>path</code> object composed of the directory argument from which the iterator was
  2462. constructed with filename of the directory entry appended as if by <code>operator/=</code>. </p>
  2463. <p>Directory iteration shall not yield directory entries for the current (<i>dot</i>)
  2464. and parent (<i>dot dot</i>) directories.</p>
  2465. <p>The order of directory entries obtained by dereferencing successive
  2466. increments of a <code>directory_iterator</code> is unspecified.</p>
  2467. <blockquote>
  2468. <p>[<i>Note:</i> Programs performing directory iteration may wish to test if the
  2469. path obtained by dereferencing a directory iterator actually exists. It could be
  2470. a
  2471. symbolic link to a non-existent file. Programs recursively
  2472. walking directory trees for purposes of removing and renaming entries may wish
  2473. to avoid following symbolic links.</p>
  2474. <p>If a file is removed from or added to a directory after the
  2475. construction of a <code>directory_iterator</code> for the directory, it is
  2476. unspecified whether or not subsequent incrementing of the iterator will ever
  2477. result in an iterator whose value is the removed or added directory entry. See
  2478. ISO/IEC 9945 <code><a href="http://www.opengroup.org/onlinepubs/000095399/functions/readdir_r.html">readdir_r()</a></code>. <i>—end note</i>]</p>
  2479. </blockquote>
  2480. <h3><a name="directory_iterator-members"><code>directory_iterator</code> members</a>
  2481. [directory_iterator.members]</h3>
  2482. <p><code><a name="directory_iterator-default-ctor">directory_iterator</a>()
  2483. noexcept;</code></p>
  2484. <blockquote>
  2485. <p><i>Effects:</i> Constructs the end iterator.</p>
  2486. </blockquote>
  2487. <pre><code>explicit <a name="directory_iterator-ctor-path">directory_iterator</a>(</code>const path&amp; p, <a href="#directory_options">directory_options</a> opts = directory_options::none<code>);
  2488. directory_iterator(</code>const path&amp; p, system::error_code&amp; ec<code>);
  2489. directory_iterator(</code>const path&amp; p, <a href="#directory_options">directory_options</a> opts, system::error_code&amp; ec<code>);</code></pre>
  2490. <blockquote>
  2491. <p><i>Effects:</i> Constructs an iterator representing the first
  2492. entry in the directory <code>p</code> resolves to, if any; otherwise, the end iterator.
  2493. If opening the directory fails with a <code>permission_denied</code> error and <code>(opts &amp; directory_options::skip_permission_denied) != 0</code>,
  2494. constructs the end iterator and ignores the error (the operation completes successfully). If <code>opts</code> is not specified, it is assumed to be <code>directory_options::none</code>.</p>
  2495. <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
  2496. <p>[<i>Note:</i> To iterate over the current directory, use <code>directory_iterator(&quot;.&quot;)</code> rather than <code>directory_iterator(&quot;&quot;)</code>. <i>—end note</i>]</p>
  2497. </blockquote>
  2498. <pre>directory_iterator&amp; <a name="directory_iterator-increment">operator++</a>();
  2499. directory_iterator&amp; increment(system::error_code&amp; ec);</pre>
  2500. <blockquote>
  2501. <p><i>Effects:</i> As specified by the C++ Standard, 24.1.1 Input iterators [input.iterators]. In case of error the iterator is left in the end state.</p>
  2502. <p><i>Returns:</i> <code>*this</code>.</p>
  2503. <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
  2504. </blockquote>
  2505. <h3><a name="directory_iterator-non-member-functions"><code>directory_iterator</code> non-member functions</a></h3>
  2506. <pre>const directory_iterator&amp; begin(const directory_iterator&amp; iter);</pre>
  2507. <blockquote>
  2508. <p><i>Returns: </i><code>iter</code>.</p>
  2509. </blockquote>
  2510. <pre>directory_iterator end(const directory_iterator&amp;);</pre>
  2511. <blockquote>
  2512. <p><i>Returns: </i><code>directory_iterator()</code>.</p>
  2513. </blockquote>
  2514. <h2><a name="Class-recursive_directory_iterator">Class <code>recursive_directory_iterator</code>
  2515. [class.rec.dir.itr]</a></h2>
  2516. <p>Objects of type <code>recursive_directory_iterator</code> provide standard library
  2517. compliant iteration over the contents of a directory, including recursion into
  2518. its sub-directories.</p>
  2519. <pre>namespace boost
  2520. {
  2521. namespace filesystem
  2522. {
  2523. class recursive_directory_iterator :
  2524. public iterator&lt;input_iterator_tag, directory_entry&gt;
  2525. {
  2526. public:
  2527. // constructors and destructor
  2528. recursive_directory_iterator() noexcept;
  2529. recursive_directory_iterator(const recursive_directory_iterator&amp;);
  2530. explicit recursive_directory_iterator(const path&amp; p,
  2531. <a href="#directory_options">directory_options</a> opts = directory_options::none);
  2532. recursive_directory_iterator(const path&amp; p,
  2533. <a href="#directory_options">directory_options</a> opts, system::error_code&amp; ec);
  2534. // deprecated constructors, use overloads accepting directory_options instead
  2535. explicit recursive_directory_iterator(const path&amp; p,
  2536. <a href="#symlink_option">symlink_option</a> opts = symlink_option::none);
  2537. recursive_directory_iterator(const path&amp; p,
  2538. <a href="#symlink_option">symlink_option</a> opts, system::error_code&amp; ec);
  2539. recursive_directory_iterator(const path&amp; p, system::error_code&amp; ec);
  2540. ~recursive_directory_iterator();
  2541. // observers
  2542. int depth() const noexcept;
  2543. bool recursion_pending() const noexcept;
  2544. // deprecated observers
  2545. int level() const noexcept;
  2546. bool no_push_pending() const noexcept;
  2547. // modifiers
  2548. recursive_directory_iterator&amp; operator=(const recursive_directory_iterator&amp;);
  2549. recursive_directory_iterator&amp; operator++();
  2550. recursive_directory_iterator&amp; increment(system::error_code&amp; ec);
  2551. void pop();
  2552. void pop(system::error_code&amp; ec);
  2553. void disable_recursion_pending(bool value = true) noexcept;
  2554. // deprecated modifiers
  2555. void no_push(bool value = true);
  2556. // other members as required by
  2557. // C++ Std, Input iterators [input.iterators]
  2558. private:
  2559. <i><b> // actual data members will probably be stored in a shared object,
  2560. // or some similar mechanism, to achieve the required input iterator
  2561. // copy semantics</b></i>
  2562. int m_depth; <b><i>// for exposition only</i></b>
  2563. bool m_recursion_pending; <i><b>// for exposition only</b></i>
  2564. <a href="#directory_options">directory_options</a> m_options; <i><b>// for exposition only</b></i>
  2565. };
  2566. } // namespace filesystem
  2567. } // namespace boost</pre>
  2568. <p>The behavior of a <code>recursive_directory_iterator</code> is the same
  2569. as a <code>directory_iterator</code> unless otherwise specified.</p>
  2570. <ul>
  2571. <li>Incrementing a <code>recursive_directory_iterator</code> pointing to a
  2572. directory causes that directory itself to be iterated over, as specified by
  2573. the <code>operator++</code> and <code>increment</code> functions.<br>
  2574. &nbsp;</li>
  2575. <li>When a <code>recursive_directory_iterator</code> reaches the end of the directory currently being iterated
  2576. over, or when <code>pop()</code> is called, <code>m_depth</code> is
  2577. decremented, and iteration of the parent directory continues.</li>
  2578. </ul>
  2579. <pre>recursive_directory_iterator() noexcept;</pre>
  2580. <blockquote>
  2581. <p><i>Effects:</i> Constructs the end iterator.</p>
  2582. </blockquote>
  2583. <pre>explicit recursive_directory_iterator(const path&amp; p, <a href="#directory_options">directory_options</a> opts = directory_options::none);
  2584. recursive_directory_iterator(const path&amp; p, <a href="#directory_options">directory_options</a> opts, system::error_code&amp; ec);
  2585. explicit recursive_directory_iterator(const path&amp; p, <a href="#symlink_option">symlink_option</a> opts = symlink_option::none);
  2586. recursive_directory_iterator(const path&amp; p, <a href="#symlink_option">symlink_option</a> opts, system::error_code&amp; ec);
  2587. recursive_<code>directory_iterator(</code>const path&amp; p, system::error_code&amp; ec<code>);</code></pre>
  2588. <blockquote>
  2589. <p><i>Effects:</i>&nbsp; Constructs an iterator representing the first
  2590. entry in the directory <code>p</code> resolves to, if any; otherwise, the end iterator.</p>
  2591. <p><i>Postcondition: </i>Unless the end iterator was constructed,<i> </i><code>depth() == 0 &amp;&amp; recursion_pending() == true &amp;&amp; m_options == opts</code>.
  2592. For the signature without the <code>opts</code> argument, <code>opts</code> is assumed to be <code>directory_options::none</code>.</p>
  2593. <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
  2594. <p>[<i>Note:</i> To iterate over the current directory, use <code>recursive_directory_iterator(&quot;.&quot;)</code> rather than <code>recursive_directory_iterator(&quot;&quot;)</code>. <i>—end note</i>]</p>
  2595. <p>[<i>Note:</i> By default, <code>recursive_directory_iterator</code> does not
  2596. follow directory symlinks. To follow directory symlinks, specify <code>directory_options::follow_directory_symlink</code> in <code>opts</code>. <i>—end note</i>]</p>
  2597. </blockquote>
  2598. <pre>int depth() const noexcept;
  2599. int level() const noexcept;</pre>
  2600. <blockquote>
  2601. <p><i>Requires:</i> <code>*this != recursive_directory_iterator()</code>.</p>
  2602. <p><i>Returns:</i> <code>m_depth</code>.</p>
  2603. </blockquote>
  2604. <pre>bool recursion_pending() const noexcept;</pre>
  2605. <blockquote>
  2606. <p><i>Requires:</i> <code>*this != recursive_directory_iterator()</code>.</p>
  2607. <p><i>Returns:</i> <code>m_recursion_pending</code>.</p>
  2608. </blockquote>
  2609. <pre>bool no_push_pending() const noexcept;</pre>
  2610. <blockquote>
  2611. <p><i>Requires:</i> <code>*this != recursive_directory_iterator()</code>.</p>
  2612. <p><i>Returns:</i> <code>!recursion_pending()</code>.</p>
  2613. </blockquote>
  2614. <pre><code>recursive_directory_iterator</code>&amp; <a name="recursive_directory_iterator-increment">operator++</a>();
  2615. recursive_directory_iterator&amp; increment(system::error_code&amp; ec);</pre>
  2616. <blockquote>
  2617. <p><i>Effects:</i> As specified by the C++ Standard, 24.1.1 Input iterators [input.iterators],
  2618. except:</p>
  2619. <ul>
  2620. <li>
  2621. <p>if <code>recursion_pending() &amp;&amp; is_directory(this-&gt;status())
  2622. &amp;&amp; (!is_symlink(this-&gt;symlink_status()) || (m_options &amp; directory_options::follow_directory_symlink) != 0)</code> then:
  2623. <ul>
  2624. <li>
  2625. <p>directory <code>(*this)-&gt;path()</code> is opened and recursively iterated into and <code>m_depth</code> is incremented;</p>
  2626. </li>
  2627. <li>
  2628. <p>if opening the directory fails with a <code>permission_denied</code> error and <code>(m_options &amp; directory_options::skip_permission_denied) != 0</code>,
  2629. increment the iterator on the current level and ignore the error (the operation completes successfully).</p>
  2630. </li>
  2631. </ul>
  2632. </p>
  2633. </li>
  2634. <li>if there are no more directory entries at this level then <code>m_depth</code>
  2635. is decremented and iteration of the parent directory resumes.</li>
  2636. </ul>
  2637. <p>If the operation completes with an error, then
  2638. <ul>
  2639. <li>if <code>(m_options &amp; directory_options::pop_on_error) != 0</code>, the iterator is left in a state as if after repeatedly calling <code>pop()</code> until it succeeds or the iterator becomes equal to an end iterator; any <code>pop()</code> failures are not reported to the caller;</li>
  2640. <li>otherwise, the iterator is left equal to an end iterator.</li>
  2641. </ul>
  2642. </p>
  2643. <p><i>Postcondition:</i> <code>recursion_pending() == true</code>.</p>
  2644. <p><i>Returns:</i> <code>*this</code>.</p>
  2645. <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
  2646. </blockquote>
  2647. <pre>void pop();
  2648. void pop(system::error_code&amp; ec);</pre>
  2649. <blockquote>
  2650. <p><i>Requires:</i> <code>*this != recursive_directory_iterator()</code>.</p>
  2651. <p><i>Effects:</i> If <code>depth() == 0</code>, set <code>*this</code> to <code>recursive_directory_iterator()</code>.
  2652. Otherwise, <code>--m_depth</code>, cease iteration of the directory currently being
  2653. iterated over, and continue iteration over the parent directory.</p>
  2654. <p>If the operation completes with an error, then
  2655. <ul>
  2656. <li>if <code>(m_options &amp; directory_options::pop_on_error) != 0</code>, the iterator is left in a state as if after repeatedly calling <code>pop()</code> until it succeeds or the iterator becomes equal to an end iterator; any <code>pop()</code> failures are not reported to the caller;</li>
  2657. <li>otherwise, the iterator is left equal to an end iterator.</li>
  2658. </ul>
  2659. </p>
  2660. </blockquote>
  2661. <pre>void disable_recursion_pending(bool value = true) noexcept;
  2662. void no_push(bool value = true) noexcept;</pre>
  2663. <blockquote>
  2664. <p><i>Requires:</i> <code>*this != recursive_directory_iterator()</code>.</p>
  2665. <p><i>Postcondition:</i> <code>recursion_pending() == !value</code>.</p>
  2666. <p>[<i>Note:</i> These functions are used to prevent
  2667. unwanted recursion into a directory. <i>—end note</i>]</p>
  2668. </blockquote>
  2669. <h3><a name="recursive_directory_iterator-non-member-functions"><code>recursive_directory_iterator</code> non-member functions</a></h3>
  2670. <pre>const recursive_directory_iterator&amp; begin(const recursive_directory_iterator&amp; iter);</pre>
  2671. <blockquote>
  2672. <p><i>Returns: </i><code>iter</code>.</p>
  2673. </blockquote>
  2674. <pre>recursive_directory_iterator end(const recursive_directory_iterator&amp;);</pre>
  2675. <blockquote>
  2676. <p><i>Returns: </i><code>recursive_directory_iterator()</code>.</p>
  2677. </blockquote>
  2678. <h2><a name="Operational-functions">Operational functions</a> [fs.op.funcs]</h2>
  2679. <p>Operational functions query or modify files, including directories, in external
  2680. storage.</p>
  2681. <p>Operational functions access a file by resolving an
  2682. object of class <code>path</code> to a particular file in a file hierarchy. The
  2683. path is resolved as if by the ISO/IEC 9945 <a href="http://www.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap04.html#tag_04_11">Pathname Resolution</a> mechanism.</p>
  2684. <p>[<i>Note: </i>Because hardware failures, network failures, <a href="#file-system-race">file system races</a>, and many
  2685. other kinds of errors occur frequently in file system operations, users should be aware
  2686. that any filesystem operational function, no matter how apparently innocuous, may encounter
  2687. an error.&nbsp;See <a href="#Error-reporting">Error reporting</a>. <i>—end note</i>]</p>
  2688. <pre>path <a name="absolute">absolute</a>(const path&amp; p, const path&amp; base=current_path());</pre>
  2689. <blockquote>
  2690. <p><i>Returns:</i> A <a href="#Absolute-path">absolute path</a> composed according to the
  2691. following table</p>
  2692. <table border="1" cellpadding="5" cellspacing="0" bordercolor="#111111" style="border-collapse: collapse">
  2693. <tr>
  2694. <td align="center">&nbsp;</td>
  2695. <td align="center"><b><code>p.<br>
  2696. has_root_directory()</code></b></td>
  2697. <td align="center"><b><code>!p.has_root_directory()</code></b></td>
  2698. </tr>
  2699. <tr>
  2700. <td align="center"><b><code>p.has_root_name()</code></b></td>
  2701. <td align="left"><code>return p</code></td>
  2702. <td align="left"><code>return<br>
  2703. &nbsp;p.root_name()<br>
  2704. &nbsp;/ absolute(base)<br>
  2705. &nbsp;&nbsp;&nbsp; .root_directory()<br>
  2706. &nbsp;/ absolute(base)<br>
  2707. &nbsp;&nbsp;&nbsp; .relative_path()<br>
  2708. &nbsp;/ p.relative_path()</code></td>
  2709. </tr>
  2710. <tr>
  2711. <td align="center"><b><code>!p.has_root_name()</code></b></td>
  2712. <td align="left"><code>return<br>
  2713. &nbsp;absolute(base)<br>
  2714. &nbsp; .root_name()<br>
  2715. &nbsp;/ p</code></td>
  2716. <td align="left"><code>return absolute(base)<br>
  2717. &nbsp;/ p</code></td>
  2718. </tr>
  2719. </table>
  2720. <p>[<i>Note:</i> For the returned path, <code>rp,</code> <code>rp.is_absolute()</code> is true. <i>—end note</i>]</p>
  2721. <p><i>Throws:</i> If <code>base.is_absolute()</code> is true, throws only if
  2722. memory allocation fails.</p>
  2723. </blockquote>
  2724. <pre>path <a name="canonical">canonical</a>(const path&amp; p, const path&amp; base = current_path());
  2725. path canonical(const path&amp; p, system::error_code&amp; ec);
  2726. path canonical(const path&amp; p, const path&amp; base, system::error_code&amp; ec);</pre>
  2727. <blockquote>
  2728. <p><i>Overview:</i> Converts <code>p</code>, which must exist, to an absolute
  2729. path that has no symbolic link, <a href="#Dot">dot</a>,
  2730. or <a href="#Dot">dot-dot</a> elements. </p>
  2731. <p><i>Returns:</i> A <a href="#canonical-path">canonical path</a> that refers to
  2732. the same file system object as <code>absolute(p,base)</code>. For the overload
  2733. without a <code>base</code> argument, <code>base</code> is <code>current_path()</code>.</p>
  2734. <p><i>Throws:</i>&nbsp; As specified in <a href="#Error-reporting">Error reporting</a>.</p>
  2735. <p><i>Remarks:</i> <code>!exists(p)</code> is an error.</p>
  2736. <p>[<i>Note:</i> Canonical pathnames allow security checking of a path (eg.
  2737. does this path live in /home/goodguy or /home/badguy?)&nbsp; —end note]</p>
  2738. </blockquote>
  2739. <pre>void <a name="copy">copy</a>(const path&amp; from, const path&amp; to);
  2740. void copy(const path&amp; from, const path&amp; to, system::error_code&amp; ec);</pre>
  2741. <blockquote>
  2742. <p><i>Effects:</i> As if</p>
  2743. <blockquote>
  2744. <pre>file_status s(symlink_status(from<i>[</i><code>, ec</code><i>]</i>));
  2745. if(is_symlink(s))
  2746. copy_symlink(from, to<i>[</i><code>, ec</code><i>]</i>);
  2747. else if(is_directory(s))
  2748. copy_directory(from, to<i>[</i><code>, ec</code><i>]</i>);
  2749. else if(is_regular_file(s))
  2750. copy_file(from, to, copy_option::fail_if_exists<i>[</i><code>, ec</code><i>]</i>);
  2751. else
  2752. <i> Report error as specified in <a href="#Error-reporting">Error reporting</a>.</i></pre>
  2753. </blockquote>
  2754. <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
  2755. </blockquote>
  2756. <pre>void <a name="copy_directory">copy_directory</a>(const path&amp; from, const path&amp; to);
  2757. void copy_directory(const path&amp; from, const path&amp; to, system::error_code&amp; ec);</pre>
  2758. <blockquote>
  2759. <table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse"
  2760. bordercolor="#111111" width="90%" bgcolor="#E0E0E0">
  2761. <tr>
  2762. <td width="100%">
  2763. <p><i>This function is poorly named; it should probably be an overload of
  2764. <code>create_directory</code> with an additional argument.</i></td>
  2765. </tr>
  2766. </table>
  2767. <p><i>Effects: </i>Creates directory <code>to</code>, with
  2768. attributes copied from directory <code>from</code>. The set of attributes
  2769. copied is operating system dependent.</p>
  2770. <blockquote>
  2771. <table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse"
  2772. bordercolor="#111111" width="90%" bgcolor="#E8FFE8">
  2773. <tr>
  2774. <td width="100%">
  2775. <p>[<i>Note:</i> For ISO 9945/POSIX based operating systems the
  2776. attributes are those copied by native API <code>stat(from.c_str(), &amp;from_stat)</code>
  2777. followed by <code>mkdir(to.c_str(),from_stat.st_mode)</code>.&nbsp; For
  2778. Windows based operating systems the attributes are those copied by native
  2779. API <code>CreateDirectoryExW(from.c_str(), to.c_str(), 0)</code>.&nbsp; <i>
  2780. —end note</i>]</td>
  2781. </tr>
  2782. </table>
  2783. </blockquote>
  2784. <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
  2785. </blockquote>
  2786. <pre>void copy_file(const path&amp; from, const path&amp; to);
  2787. void copy_file(const path&amp; from, const path&amp; to, system::error_code&amp; ec);</pre>
  2788. <blockquote>
  2789. <p><i>Effects: </i><code>copy_file(from, to, copy_option::fail_if_exists</code><i>[</i><code>, ec</code><i>]</i><code>)</code>.</p>
  2790. <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
  2791. </blockquote>
  2792. <pre>void <a name="copy_file">copy_file</a>(const path&amp; from, const path&amp; to, <a href="#copy_option">copy_option</a> option);
  2793. void <a name="copy_file2">copy_file</a>(const path&amp; from, const path&amp; to, <a href="#copy_option">copy_option</a> option, system::error_code&amp; ec);</pre>
  2794. <blockquote>
  2795. <p><i>Effects:</i> If <code>option == copy_option::</code><code>fail_if_exists &amp;&amp; exists(to)</code>, an error is reported. Otherwise, the contents and attributes of the file <code>from</code> resolves to are copied to the file <code>to</code> resolves to.</p>
  2796. <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
  2797. </blockquote>
  2798. <pre>void <a name="copy_symlink">copy_symlink</a>(const path&amp; existing_symlink, const path&amp; new_symlink);
  2799. void copy_symlink(const path&amp; existing_symlink, const path&amp; new_symlink, system::error_code&amp; ec);</pre>
  2800. <blockquote>
  2801. <p><i>Effects: </i><code>create_symlink(read_symlink(existing_symlink</code><i>[</i><code>, ec</code><i>]</i><code>), new_symlink</code><i>[</i><code>, ec</code><i>]</i><code>)</code>.</p>
  2802. <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
  2803. </blockquote>
  2804. <pre>bool <a name="create_directories">create_directories</a>(const path&amp; p);
  2805. bool <a name="create_directories2">create_directories</a>(const path&amp; p, system::error_code&amp; ec);</pre>
  2806. <blockquote>
  2807. <p><i>Effects:</i> Establishes the postcondition by calling <code>
  2808. create_directory()</code> for any element of <code>p</code> that does not
  2809. exist.</p>
  2810. <p><i>Postcondition:</i> <code>is_directory(p)</code></p>
  2811. <p><i>Returns:</i> <code>true</code> if a new directory was created, otherwise <code>
  2812. false</code>.</p>
  2813. <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
  2814. <p><i>Complexity:</i> <i>O(n+1)</i> where <i>n</i> is the number of elements
  2815. of <code>p</code> that do not exist.</p>
  2816. </blockquote>
  2817. <pre>bool <a name="create_directory">create_directory</a>(const path&amp; p);
  2818. bool <a name="create_directory2">create_directory</a>(const path&amp; p, system::error_code&amp; ec);</pre>
  2819. <blockquote>
  2820. <p><i>Effects:</i> Establishes the postcondition by attempting to create the
  2821. directory <code>p</code> resolves to, as if by ISO/IEC 9945 <code><a href="http://www.opengroup.org/onlinepubs/000095399/functions/mkdir.html">
  2822. mkdir()</a></code> with a second argument of S_IRWXU|S_IRWXG|S_IRWXO. Creation
  2823. failure because <code>p</code> resolves to an existing directory shall not be
  2824. treated as an error. </p>
  2825. <p><i>Postcondition:</i> <code>is_directory(p)</code></p>
  2826. <p><i>Returns:</i> <code>true</code> if a new directory was created, otherwise <code>false</code>.</p>
  2827. <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
  2828. </blockquote>
  2829. <pre>void <a name="create_directory_symlink">create_directory_symlink</a>(const path&amp; to, const path&amp; new_symlink);
  2830. void create_directory_symlink(const path&amp; to, const path&amp; new_symlink, system::error_code&amp; ec);</pre>
  2831. <blockquote>
  2832. <p><i>Effects:</i> Establishes the postcondition, as if by ISO/IEC 9945 <code><a href="http://www.opengroup.org/onlinepubs/000095399/functions/symlink.html">symlink()</a></code>.</p>
  2833. <p><i>
  2834. Postcondition:</i> <code>new_symlink</code> resolves to a symbolic link file that
  2835. contains an unspecified representation of <code>to</code>.</p>
  2836. <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
  2837. <p>[<i>Note:</i> Some operating systems, such as Windows, require symlink creation to
  2838. identify that the link is to a directory. Portable code should use <code>create_directory_symlink()</code> to create directory symlinks rather than <code>create_symlink()</code> <i>—end note</i>]</p>
  2839. <p>[<i>Note:</i> Some operating systems do not support symbolic links at all or support
  2840. them only for regular files.
  2841. Some file systems do not
  2842. support
  2843. symbolic links regardless of the operating system - the FAT file system used on
  2844. memory cards and flash drives, for example. <i>—end note</i>]</p>
  2845. </blockquote>
  2846. <pre>void <a name="create_hard_link">create_hard_link</a>(const path&amp; to, const path&amp; new_hard_link);
  2847. void <a name="create_hard_link2">create_hard_link</a>(const path&amp; to, const path&amp; new_hard_link, system::error_code&amp; ec);</pre>
  2848. <blockquote>
  2849. <p><i>Effects:</i> Establishes the postcondition, as if by ISO/IEC 9945 <code><a href="http://www.opengroup.org/onlinepubs/000095399/functions/link.html">link()</a></code>.</p>
  2850. <p><i>Postcondition:</i></p>
  2851. <ul>
  2852. <li>&nbsp;<code>exists(to) &amp;&amp;
  2853. exists(</code><code>new_hard_link</code><code>) &amp;&amp; equivalent(to,
  2854. </code><code>new_hard_link</code><code>)</code></li>
  2855. <li>The contents of the file or directory
  2856. <code>to</code> resolves to are unchanged.</li>
  2857. </ul>
  2858. <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
  2859. <p>[<i>Note:</i> Some operating systems do not support hard links at all or support
  2860. them only for regular files. Some file systems do not support hard
  2861. links regardless of the operating system - the FAT file system used on memory
  2862. cards and flash drives, for example. Some file systems limit the number of
  2863. links per file. <i>—end note</i>]</p>
  2864. </blockquote>
  2865. <pre>void <a name="create_symlink">create_symlink</a>(const path&amp; to, const path&amp; new_symlink);
  2866. void <a name="create_symlink2">create_symlink</a>(const path&amp; to, const path&amp; new_symlink, system::error_code&amp; ec);</pre>
  2867. <blockquote>
  2868. <p><i>Effects:</i> Establishes the postcondition, as if by ISO/IEC 9945 <code><a href="http://www.opengroup.org/onlinepubs/000095399/functions/symlink.html">symlink()</a></code>.</p>
  2869. <p><i>
  2870. Postcondition:</i> <code>new_symlink</code> resolves to a symbolic link file that
  2871. contains an unspecified representation of <code>to</code>.</p>
  2872. <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
  2873. <p>[<i>Note:</i> Some operating systems do not support symbolic links at all or support
  2874. them only for regular files.
  2875. Some file systems do not
  2876. support
  2877. symbolic links regardless of the operating system - the FAT system used on
  2878. memory cards and flash drives, for example. <i>—end note</i>]</p>
  2879. </blockquote>
  2880. <pre>path <a name="current_path">current_path</a>();
  2881. path <a name="current_path2">current_path</a>(system::error_code&amp; ec);</pre>
  2882. <blockquote>
  2883. <p><i>Returns:</i> The current working directory path, as if by ISO/IEC
  2884. 9945 <code><a href="http://www.opengroup.org/onlinepubs/000095399/functions/getcwd.html">getcwd()</a></code>. <code>is_absolute()</code> is true for the returned path.</p>
  2885. <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
  2886. <p>[<i>Note: </i>The <code>current_path()</code> name was chosen to emphasize that the return is a
  2887. path, not just a single directory name.</p>
  2888. <p>The current path as returned by many operating systems is a dangerous
  2889. global variable. It may be changed unexpectedly by a third-party or system
  2890. library functions, or by another thread.&nbsp; <i>—end note</i>]</p>
  2891. </blockquote>
  2892. <pre>void current_path(const path&amp; p);
  2893. void current_path(const path&amp; p, system::error_code&amp; ec);</pre>
  2894. <blockquote>
  2895. <p><i>Effects:</i> Establishes the postcondition, as if by ISO/IEC 9945 <code><a href="http://www.opengroup.org/onlinepubs/000095399/functions/chdir.html">chdir()</a></code>.</p>
  2896. <p><i>Postcondition:</i> <code>equivalent(p, current_path())</code>.</p>
  2897. <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
  2898. <p>[<i>Note: </i>The current path for many operating systems is a dangerous
  2899. global state. It may be changed unexpectedly by a third-party or system
  2900. library functions, or by another thread.&nbsp; <i>—end note</i>]</p>
  2901. </blockquote>
  2902. <pre>bool <a name="exists">exists</a>(file_status s) noexcept;</pre>
  2903. <blockquote>
  2904. <p><i>Returns:</i> <code>status_known(s) &amp;&amp; s.type() != file_not_found</code></p>
  2905. </blockquote>
  2906. <pre>bool <a name="exists2">exists</a>(const path&amp; p);
  2907. bool <a name="exists3">exists</a>(const path&amp; p, system::error_code&amp; ec) noexcept;</pre>
  2908. <blockquote>
  2909. <p><i>Returns:</i> <code>exists(status(p))</code> or <code>exists(status(p, ec))</code>,
  2910. respectively. If ec != 0 and an error</p>
  2911. <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
  2912. </blockquote>
  2913. <pre><code>bool <a name="equivalent">equivalent</a>(const path&amp; p1, const path&amp; p2);
  2914. bool <a name="equivalent2">equivalent</a>(const path&amp; p1, const path&amp; p2, system::error_code&amp; ec);</code></pre>
  2915. <blockquote>
  2916. <p><i>Effects:</i> Determines <code>file_status s1</code> and <code>s2</code>, as if by <code>status(p1)</code> and&nbsp; <code>status(p2)</code>,
  2917. respectively.</p>
  2918. <p><i>Returns:</i> <code>true</code>, if <code>sf1 ==
  2919. sf2</code> and <code>p1</code> and <code>p2</code> resolve to the same file
  2920. system entity, else <code>false</code>.</p>
  2921. <blockquote>
  2922. <p>Two paths are considered to resolve to the same
  2923. file system entity if two candidate entities reside on the same device at the
  2924. same location. This is determined as if by the values of the ISO/IEC 9945 <code><a href="http://www.opengroup.org/onlinepubs/000095399/basedefs/sys/stat.h.html">stat</a></code> structure<code>,</code> obtained as if by <code><a href="http://www.opengroup.org/onlinepubs/000095399/functions/stat.html">stat()</a></code> for the two paths, having equal <code>st_dev</code> values
  2925. and equal <code>st_ino</code> values.</p>
  2926. <p>[<i>Note:</i> ISO/IEC 9945 requires that <i>&quot;st_dev</i> must be unique within a Local Area Network&quot;. Conservative
  2927. ISO/IEC 9945 implementations may also wish to check for equal <code>st_size</code> and <code>st_mtime</code> values. <i>Windows</i> implementations may use <code>GetFileInformationByHandle()</code> as a surrogate for <code>stat()</code>,
  2928. and consider &quot;same&quot; to be equal values for <code>dwVolumeSerialNumber</code>, <code>nFileIndexHigh</code>, <code>nFileIndexLow</code>, <code>nFileSizeHigh</code>, <code>nFileSizeLow</code>, <code>ftLastWriteTime.dwLowDateTime</code>, and <code>ftLastWriteTime.dwHighDateTime</code>. <i>—end note</i>]</p>
  2929. </blockquote>
  2930. <p><i>Throws:</i> <code>filesystem_error</code> if <code>(!exists(s1) &amp;&amp; !exists(s2)) || (is_other(s1) &amp;&amp; is_other(s2))</code>,
  2931. otherwise as specified in <a href="#Error-reporting">Error reporting</a>.</p>
  2932. </blockquote>
  2933. <pre>uintmax_t <a name="file_size">file_size</a>(const path&amp; p);
  2934. uintmax_t <a name="file_size2">file_size</a>(const path&amp; p, system::error_code&amp; ec);</pre>
  2935. <blockquote>
  2936. <p><i>Returns:</i> If <code>exists(p) &amp;&amp; is_regular_file(p)</code>, the size
  2937. in bytes
  2938. of the file <code>p</code> resolves to, determined as if by the value of
  2939. the ISO/IEC 9945 <code><a href="http://www.opengroup.org/onlinepubs/000095399/basedefs/sys/stat.h.html">stat</a></code> structure member <code>st_size</code> obtained as if by
  2940. ISO/IEC 9945 <code><a href="http://www.opengroup.org/onlinepubs/000095399/functions/stat.html">stat()</a></code>.
  2941. Otherwise, <code>static_cast&lt;uintmax_t&gt;(-1)</code>.</p>
  2942. <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
  2943. </blockquote>
  2944. <pre>uintmax_t <a name="hard_link_count">hard_link_count</a>(const path&amp; p);
  2945. uintmax_t hard_link_count(const path&amp; p, system::error_code&amp; ec);</pre>
  2946. <blockquote>
  2947. <p><i>Returns:</i> The number of hard links for <code>p</code>.</p>
  2948. <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
  2949. </blockquote>
  2950. <pre>const path&amp; <a name="initial_path">initial_path</a>();
  2951. const path&amp; <a name="initial_path2">initial_path</a>(<code>system::error_code&amp; ec</code>);</pre>
  2952. <blockquote>
  2953. <p><i>Returns:</i> <code>current_path()</code> as of the first call to <code>initial_path()</code>.</p>
  2954. <p>[<i>Note:</i> <code>initial_path()</code> is not thread safe, and may return an undesirable result
  2955. if called subsequent to a change to the current directory. These problems can
  2956. be avoided by calling <code>initial_path()</code> immediately on entry to
  2957. main().&nbsp; <i>—end note</i>]</p>
  2958. <p><i>Throws:</i> For the first call, as specified in <a href="#Error-reporting">Error reporting</a>. Subsequent calls throw nothing.</p>
  2959. </blockquote>
  2960. <pre>bool <code><a name="is_directory">is_directory</a></code>(file_status s) noexcept;</pre>
  2961. <blockquote>
  2962. <p><i>Returns:</i> <code>s.type() == directory_file</code></p>
  2963. </blockquote>
  2964. <pre><code>bool <a name="is_directory2">is_directory</a>(const path&amp; p);
  2965. bool <a name="is_directory3">is_directory</a>(const path&amp; p, system::error_code&amp; ec) noexcept;</code></pre>
  2966. <blockquote>
  2967. <p><i>Returns:</i> <code>is_directory(status(p))</code> or <code>is_directory(status(p, ec))</code>,
  2968. respectively.</p>
  2969. <p><i>Throws:</i> <code>filesystem_error</code>; overload with <code>error_code&amp;</code> throws
  2970. nothing.</p>
  2971. </blockquote>
  2972. <pre><code>bool <a name="is_empty">is_empty</a>(const path&amp; p);
  2973. bool <a name="is_empty2">is_empty</a></a>(const path&amp; p, system::error_code&amp; ec);</code></pre>
  2974. <blockquote>
  2975. <p><i>Effects:</i> Determines <code>file_status s</code>, as if by <code>status(p, ec)</code>.</p>
  2976. <p><i>Returns:</i> <code>is_directory(s)<br>
  2977. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ? directory_iterator(p) == directory_iterator()<br>
  2978. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : file_size(p) == 0;</code></p>
  2979. </blockquote>
  2980. <pre>bool <code><a name="is_regular_file">is_regular_file</a></code>(file_status s) noexcept;</pre>
  2981. <blockquote>
  2982. <p><i>Returns:</i> <code>s.type() == regular_file</code></p>
  2983. </blockquote>
  2984. <pre><code>bool <a name="is_regular_file2">is_regular_file</a>(const path&amp; p);</code></pre>
  2985. <blockquote>
  2986. <p><i>Returns:</i> <code>is_regular_file(status(p))</code>.</p>
  2987. <p><i>Throws:</i> <code>filesystem_error</code> if <code>status(p)</code> would throw <code>filesystem_error.</code></p>
  2988. </blockquote>
  2989. <pre><code>bool <a name="is_regular_file3">is_regular_file</a>(const path&amp; p, system::error_code&amp; ec) noexcept;</code></pre>
  2990. <blockquote>
  2991. <p><i>Effects:</i> Sets <code>ec</code> as if by <code>status(p, ec)</code>. [<i>Note:</i> <code>status_error</code>, <code>file_not_found</code> and <code>type_unknown</code> cases set <code>ec</code> to error values. To distinguish between cases, call the <code>status</code> function directly. <i>—end
  2992. note</i>] </p>
  2993. <p><i>Returns:</i> <code>is_regular_file(status(p, ec))</code>.</p>
  2994. </blockquote>
  2995. <pre>bool <a name="is_other">is_other</a>(file_status s) noexcept;</pre>
  2996. <blockquote>
  2997. <p><i>Returns:</i> <code>return exists(s) &amp;&amp; !is_regular_file(s) &amp;&amp; !is_directory(s) &amp;&amp; !is_symlink(s)</code></p>
  2998. </blockquote>
  2999. <pre><code>bool <a name="is_other2">is_other</a>(const path&amp; p);
  3000. bool <a name="is_other3">is_other</a>(const path&amp; p, system::error_code&amp; ec) noexcept;</code></pre>
  3001. <blockquote>
  3002. <p><i>Returns:</i> <code>is_other(status(p))</code> or <code>is_other(status(p, ec))</code>,
  3003. respectively.</p>
  3004. <p><i>Throws:</i> <code>filesystem_error</code>; overload with <code>error_code&amp;</code> throws
  3005. nothing.</p>
  3006. </blockquote>
  3007. <pre>bool <a name="is_symlink">is_symlink</a>(file_status s) noexcept;</pre>
  3008. <blockquote>
  3009. <p><i>Returns:</i> <code>s.type() == symlink_file</code></p>
  3010. </blockquote>
  3011. <pre><code>bool <a name="is_symlink2">is_symlink</a>(const path&amp; p);
  3012. bool <a name="is_symlink3">is_symlink</a>(const path&amp; p, system::error_code&amp; ec) noexcept;</code></pre>
  3013. <blockquote>
  3014. <p><i>Returns:</i> <code>is_symlink(symlink_status(p))</code> or <code>is_symlink(symlink_status(p, ec))</code>,
  3015. respectively.</p>
  3016. <p><i>Throws:</i> <code>filesystem_error</code>; overload with <code>error_code&amp;</code> throws
  3017. nothing.</p>
  3018. </blockquote>
  3019. <pre>std::time_t <a name="last_write_time">last_write_time</a>(const path&amp; p);
  3020. std::time_t <a name="last_write_time2">last_write_time</a>(const path&amp; p<code>, system::error_code&amp; ec</code>);</pre>
  3021. <blockquote>
  3022. <p><i>Returns:</i> The time of last data modification of <code>p</code>, determined as if by the
  3023. value of the ISO/IEC 9945 <code><a href="http://www.opengroup.org/onlinepubs/000095399/basedefs/sys/stat.h.html">stat</a></code> structure member <code>st_mtime</code>&nbsp; obtained
  3024. as if by ISO/IEC 9945 <code><a href="http://www.opengroup.org/onlinepubs/000095399/functions/stat.html">stat()</a></code>.</p>
  3025. <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
  3026. </blockquote>
  3027. <pre>void <a name="last_write_time3">last_write_time</a>(const path&amp; p, const std::time_t new_time);
  3028. void <a name="last_write_time4">last_write_time</a>(const path&amp; p, const std::time_t new_time<code>, system::error_code&amp; ec</code>);</pre>
  3029. <blockquote>
  3030. <p><i>Effects:</i> Sets the time of last data modification of the file
  3031. resolved to by <code>p</code> to <code>new_time</code>, as if by ISO/IEC
  3032. 9945 <code><a href="http://www.opengroup.org/onlinepubs/000095399/functions/stat.html">stat()</a></code> followed by
  3033. ISO/IEC 9945 <a href="http://www.opengroup.org/onlinepubs/000095399/functions/utime.html"><code>utime()</code></a>.</p>
  3034. <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
  3035. <p>[<i>Note:</i> A postcondition of <code>last_write_time(p) == new_time</code> is not specified since it might not hold for file systems
  3036. with coarse time granularity. <i>—end note</i>]</p>
  3037. </blockquote>
  3038. <pre>void <a name="permissions">permissions</a>(const path&amp; p, <a href="#symlink_perms">perms</a> prms);
  3039. void permissions(const path&amp; p, <a href="#symlink_perms">perms</a> prms, system::error_code&amp; ec);</pre>
  3040. <blockquote>
  3041. <p>
  3042. <i>Requires:</i> <code>!((prms &amp; add_perms) &amp;&amp; (prms &amp; remove_perms))</code>.</p>
  3043. <p><i>Effects:</i> Applies the effective permissions bits from <code>prms</code> to the file <code>p</code> resolves to, as if by
  3044. ISO/IEC 9945 <code><a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/fchmodat.html">fchmodat()</a></code>. The effective permission bits are determined as
  3045. specified by the following table. </p>
  3046. <table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111">
  3047. <tr>
  3048. <td><b>bits present in <code>prms</code></b></td>
  3049. <td><b>Effective bits applied</b></td>
  3050. </tr>
  3051. <tr>
  3052. <td>Neither <code>add_perms</code> nor <code>remove_perms</code></td>
  3053. <td><code>prms &amp; perms_mask</code></td>
  3054. </tr>
  3055. <tr>
  3056. <td><code>add_perms</code></td>
  3057. <td>
  3058. <p><code>status(p).permissions() | (prms &amp; <a href="#perms_mask">perms_mask</a>)</code> </td>
  3059. </tr>
  3060. <tr>
  3061. <td><code>remove_perms</code></td>
  3062. <td><code>status(p)</code><code>.permissions() &amp; ~(prms &amp; <a href="#perms_mask">perms_mask</a>) </code></td>
  3063. </tr>
  3064. </table>
  3065. <p>[<i>Note:</i> Conceptually permissions are viewed as bits, but the actual
  3066. implementation may use some other mechanism. -- <i>end note</i>]</p>
  3067. <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
  3068. </blockquote>
  3069. <pre>path <a name="read_symlink">read_symlink</a>(const path&amp; p);
  3070. path read_symlink(const path&amp; p, system::error_code&amp; ec);</pre>
  3071. <blockquote>
  3072. <p><i>Returns:</i>&nbsp; If <code>p</code> resolves to a symbolic
  3073. link, a <code>path</code> object containing the contents of that symbolic
  3074. link. Otherwise an empty <code>path</code> object.</p>
  3075. <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>. [<i>Note:</i> It is an error if <code>p</code> does not
  3076. resolve to a symbolic link. <i>—end note</i>]</p>
  3077. </blockquote>
  3078. <pre>path <a name="op-relative">relative</a>(const path&amp; p, system::error_code&amp; ec);</pre>
  3079. <blockquote>
  3080. <p><i>Returns:</i> <code>relative(p, current_path(), ec)</code>.</p>
  3081. <p><i>Throws:</i>&nbsp; As specified in Error reporting.</p>
  3082. </blockquote>
  3083. <pre>path relative(const path&amp; p, const path&amp; base=current_path());
  3084. path relative(const path&amp; p, const path&amp; base, system::error_code&amp; ec);</pre>
  3085. <blockquote>
  3086. <p><i>Overview:</i> Returns <code>p</code> made relative to <code>base</code>.
  3087. Treats empty or identical paths as corner cases, not errors. Resolves symlinks
  3088. and normalizes both <code>p</code> and <code>base</code> before other
  3089. processing.</p>
  3090. <p><i>Returns:</i> <code><a href="#weakly_canonical">weakly_canonical</a>(p).<a href="#lex-relative">lexically_relative</a>(<a href="#weakly_canonical">weakly_canonical</a>(base))</code>. The second form returns <code>path()</code>
  3091. if an error occurs.</p>
  3092. <p><i>Throws:</i> As specified in Error reporting.</p>
  3093. </blockquote>
  3094. <pre>bool <a name="remove">remove</a>(const path&amp; p);
  3095. bool <a name="remove2">remove</a>(const path&amp; p, system::error_code&amp; ec);</pre>
  3096. <blockquote>
  3097. <p><i>Effects:</i>&nbsp; If <code>exists(symlink_status(p,ec))</code>, it is
  3098. removed
  3099. as if by ISO/IEC 9945 <code><a href="http://www.opengroup.org/onlinepubs/000095399/functions/remove.html">remove()</a></code>.</p>
  3100. <blockquote>
  3101. <p>[<i>Note:</i> A symbolic link is itself removed, rather than the file it
  3102. resolves to being removed. <i>—end note</i>]</p>
  3103. </blockquote>
  3104. <p><i>Postcondition:</i> <code>!exists(symlink_status(p))</code>.</p>
  3105. <p><i>Returns:</i>&nbsp; <code>false</code> if p did not exist in the first
  3106. place, otherwise <code>true</code>.</p>
  3107. <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
  3108. </blockquote>
  3109. <pre>uintmax_t <a name="remove_all">remove_all</a>(const path&amp; p);
  3110. uintmax_t <a name="remove_all2">remove_all</a>(const path&amp; p, system::error_code&amp; ec);</pre>
  3111. <blockquote>
  3112. <p><i>Effects:</i>&nbsp; Recursively deletes the contents of p if it exists,
  3113. then deletes file <code>p</code> itself,
  3114. as if by ISO/IEC 9945 <code><a href="http://www.opengroup.org/onlinepubs/000095399/functions/remove.html">remove()</a></code>.</p>
  3115. <blockquote>
  3116. <p>[<i>Note:</i> A symbolic link is itself removed, rather than the file it
  3117. resolves to being removed. <i>—end note</i>]</p>
  3118. </blockquote>
  3119. <p><i>Postcondition:</i> <code>!exists(p)</code></p>
  3120. <p><i>Returns:</i> The number of files removed.</p>
  3121. <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
  3122. </blockquote>
  3123. <pre>void <a name="rename">rename</a>(const path&amp; old_p, const path&amp; new_p);
  3124. void <a name="rename2">rename</a>(const path&amp; old_p, const path&amp; new_p, system::error_code&amp; ec);</pre>
  3125. <blockquote>
  3126. <p><i>Effects:</i> Renames <code>old_p</code> to <code>new_p</code>, as if by
  3127. ISO/IEC 9945 <code><a href="http://www.opengroup.org/onlinepubs/000095399/functions/rename.html">rename()</a></code>.</p>
  3128. <blockquote>
  3129. <p>[<i>Note:</i> If <code>old_p</code> and <code>new_p</code> resolve to the
  3130. same existing file, no action is taken. Otherwise, if <code>new_p</code> resolves to an
  3131. existing non-directory file, it is removed, while if <code>new_p</code> resolves to an
  3132. existing directory, it is removed if empty on ISO/IEC 9945 but is an error on Windows. A symbolic link is itself renamed, rather than
  3133. the file it resolves to being renamed. <i>—end note</i>]</p>
  3134. </blockquote>
  3135. <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
  3136. </blockquote>
  3137. <pre>void <a name="resize_file">resize_file</a>(const path&amp; p, uintmax_t new_size);
  3138. void <a name="resize_file2">resize_file</a>(const path&amp; p, uintmax_t new_size, system::error_code&amp; ec);</pre>
  3139. <blockquote>
  3140. <p><i>Postcondition:</i> <code>file_size() == new_size</code>.</p>
  3141. <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
  3142. <p><i>Remarks:</i> Achieves its postconditions as if by ISO/IEC 9945 <code><a href="http://www.opengroup.org/onlinepubs/000095399/functions/truncate.html">truncate()</a></code>.</p>
  3143. </blockquote>
  3144. <pre>space_info <a name="space">space</a>(const path&amp; p);
  3145. space_info <a name="space2">space</a>(const path&amp; p, system::error_code&amp; ec);</pre>
  3146. <blockquote>
  3147. <p><i>Returns:</i> An object of type <code><a href="#space_info">space_info</a></code>. The value of the <code>space_info</code> object is determined as if by
  3148. using ISO/IEC 9945 <code><a href="http://www.opengroup.org/onlinepubs/000095399/functions/statvfs.html"
  3149. style="text-decoration: none">statvfs()</a></code> to obtain an ISO/IEC 9945 struct
  3150. <code><a href="http://www.opengroup.org/onlinepubs/000095399/basedefs/sys/statvfs.h.html" style="text-decoration: none">statvfs</a></code>,
  3151. and then multiplying its <code>f_blocks</code>, <code>f_bfree</code>,
  3152. and <code>f_bavail</code> members by its <code>f_frsize</code> member,
  3153. and assigning the results to the <code>capacity</code>, <code>free</code>,
  3154. and <code>available</code> members respectively. Any members for which the
  3155. value cannot be determined shall be set to -1.</p>
  3156. <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
  3157. </blockquote>
  3158. <pre><a href="#file_status">file_status</a> <a name="status">status</a>(const path&amp; p);</pre>
  3159. <blockquote>
  3160. <p><i>Effects: </i>As if:</p>
  3161. <blockquote>
  3162. <pre>system::error_code ec;
  3163. file_status result = status(p, ec);
  3164. if (result == status_error)
  3165. throw filesystem_error(<i>implementation-supplied-message</i>, p, ec);
  3166. return result;</pre>
  3167. </blockquote>
  3168. <p><i>Returns:</i> See above.</p>
  3169. <p><i>Throws:</i> <code>filesystem_error</code>.
  3170. [<i>Note:</i> <code>result</code> values of <code>file_status(file_not_found)</code>and <code>file_status(type_unknown)</code> are not considered failures and do not
  3171. cause an exception to be
  3172. thrown.<i> —end note</i>] </p>
  3173. </blockquote>
  3174. <pre><a href="#file_status">file_status</a> <a name="status2">status</a>(const path&amp; p, system::error_code&amp; ec) noexcept;</pre>
  3175. <blockquote>
  3176. <p><i>Effects: </i></p>
  3177. <blockquote>
  3178. <p>If possible, determines the attributes
  3179. of the file <code>p</code> resolves to, as if by ISO/IEC 9945 <code><a href="http://www.opengroup.org/onlinepubs/000095399/functions/stat.html">stat()</a></code>.</p>
  3180. If, during attribute determination, the underlying file system API reports
  3181. an error, sets <code>ec</code> to indicate the specific error reported.
  3182. Otherwise, <code>ec.clear()</code>.<blockquote>
  3183. <p>[<i>Note:</i> This allows users to inspect the specifics of underlying
  3184. API errors even when the value returned by <code>status()</code> is not <code>file_status(status_error)</code>.&nbsp; <i>—end note</i>]</p>
  3185. </blockquote>
  3186. </blockquote>
  3187. <p><i>Returns:</i></p>
  3188. <blockquote>
  3189. <p>If <code>ec != error_code()</code>:</p>
  3190. <ul>
  3191. <li>If the specific error indicates that <code>p</code> cannot be resolved
  3192. because some element of the path does not exist, return <code>
  3193. file_status(file_not_found)</code>. [<i>Note:</i> ISO/IEC 9945 errors that
  3194. indicate this are ENOENT or ENOTDIR. Windows equivalents
  3195. include ERROR_FILE_NOT_FOUND, ERROR_PATH_NOT_FOUND, ERROR_INVALID_NAME,
  3196. ERROR_INVALID_PARAMETER, ERROR_BAD_PATHNAME, and ERROR_BAD_NETPATH. <i>--
  3197. end note</i>]<br>
  3198. &nbsp;</li>
  3199. <li>Otherwise, if the specific error indicates that <code>p</code> can be resolved
  3200. but the attributes cannot be determined, return <code>
  3201. file_status(type_unknown)</code>. [<i>Note: </i>For example, Windows
  3202. ERROR_SHARING_VIOLATION errors. For ISO/IEC 9945, the case never arises. <i>—end
  3203. note</i>]<br>
  3204. &nbsp;</li>
  3205. <li>Otherwise, return <code>
  3206. file_status(status_error)</code>.</li>
  3207. </ul>
  3208. <blockquote>
  3209. <p>[<i>Note:</i> These semantics distinguish between <code>p</code> being known not to exist, <code>p</code> existing but not being able to determine its attributes,
  3210. and there being an error that prevents even knowing if <code>p</code> exists. These
  3211. distinctions are important to some use cases.&nbsp;<i>—end note</i>]</p>
  3212. </blockquote>
  3213. <p>Otherwise,</p>
  3214. <ul>
  3215. <li>If the attributes indicate a regular file, as if by ISO/IEC 9945&nbsp;<a href="http://www.opengroup.org/onlinepubs/000095399/basedefs/sys/stat.h.html">S_ISREG()</a>,
  3216. return <code>
  3217. file_status(regular_file)</code>. [<i>Note:</i> <code>
  3218. regular_file</code> implies appropriate <code>&lt;fstream&gt;</code> operations
  3219. would succeed, assuming no hardware, permission, access, or file system
  3220. race
  3221. errors. Lack of
  3222. <code>regular_file</code> does not necessarily imply <code>&lt;fstream&gt;</code> operations would
  3223. fail on a directory.
  3224. <i>—end note</i>]<br>
  3225. &nbsp;</li>
  3226. <li>Otherwise, if the attributes indicate a directory, as if by ISO/IEC 9945
  3227. <a href="http://www.opengroup.org/onlinepubs/000095399/basedefs/sys/stat.h.html">S_ISDIR()</a>,
  3228. return <code>
  3229. file_status(directory_file)</code>. [<i>Note:</i> <code>directory_file</code> implies <code>
  3230. directory_iterator(p)</code>would succeed.
  3231. <i>—end note</i>]<br>
  3232. &nbsp;</li>
  3233. <li>Otherwise, if the attributes indicate a block special file, as if by ISO/IEC 9945
  3234. <a href="http://www.opengroup.org/onlinepubs/000095399/basedefs/sys/stat.h.html">S_ISBLK()</a>,
  3235. return <code>
  3236. file_status(block_file)</code>.<br>
  3237. &nbsp;</li>
  3238. <li>Otherwise, if the attributes indicate a character special file, as if by ISO/IEC 9945
  3239. <a href="http://www.opengroup.org/onlinepubs/000095399/basedefs/sys/stat.h.html">S_ISCHR()</a>,
  3240. return <code>
  3241. file_status(character_file)</code>.<br>
  3242. &nbsp;</li>
  3243. <li>Otherwise, if the attributes indicate a fifo or pipe file, as if by
  3244. ISO/IEC 9945
  3245. <a href="http://www.opengroup.org/onlinepubs/000095399/basedefs/sys/stat.h.html">S_ISFIFO()</a>,
  3246. return <code>
  3247. file_status(fifo_file)</code>.<br>
  3248. &nbsp;</li>
  3249. <li>Otherwise, if the attributes indicate a socket, as if by ISO/IEC
  3250. 9945
  3251. <a href="http://www.opengroup.org/onlinepubs/000095399/basedefs/sys/stat.h.html">S_ISSOCK()</a>,
  3252. return <code>
  3253. file_status(socket_file)</code>.<br>
  3254. &nbsp;</li>
  3255. <li>Otherwise, return <code>
  3256. file_status(type_unknown)</code>.</li>
  3257. </ul>
  3258. </blockquote>
  3259. <p><i>Remarks:</i> If a symbolic link is encountered during pathname
  3260. resolution,
  3261. pathname resolution continues using the contents of the symbolic link.</p>
  3262. </blockquote>
  3263. <pre>bool <a name="status_known">status_known</a>(file_status s) noexcept;</pre>
  3264. <blockquote>
  3265. <p><i>Returns:</i> <code>s.type() != status_error</code></p>
  3266. </blockquote>
  3267. <pre>file_status <a name="symlink_status">symlink_status</a>(const path&amp; p);
  3268. file_status <a name="symlink_status2">symlink_status</a>(const path&amp; p, system::error_code&amp; ec) noexcept;</pre>
  3269. <blockquote>
  3270. <p><i>Effects:</i>&nbsp; Same as <a href="#status">status()</a>, above,
  3271. except that the attributes
  3272. of <code>p</code> are determined as if by ISO/IEC 9945 <code><a href="http://www.opengroup.org/onlinepubs/000095399/functions/lstat.html">lstat()</a></code>.</p>
  3273. </blockquote>
  3274. <blockquote>
  3275. <p><i>Returns:</i> Same as <a href="#status">status()</a>, above, except
  3276. that if the attributes indicate a symbolic link, as if by ISO/IEC 9945 <a class="external" href="http://www.opengroup.org/onlinepubs/000095399/basedefs/sys/stat.h.html">S_ISLNK()</a>, return <code>file_status(symlink_file)</code>.</p>
  3277. <p><i>Remarks:</i> Pathname resolution terminates if <code>p</code> names a symbolic link.</p>
  3278. <p><i>Throws:</i> <code>filesystem_error</code>; overload with <code>error_code&amp;</code> throws
  3279. nothing.</p>
  3280. </blockquote>
  3281. <pre>path <a name="system_complete">system_complete</a>(const path&amp; p);
  3282. path <a name="system_complete2">system_complete</a>(const path&amp; p, system::error_code&amp; ec);</pre>
  3283. <blockquote>
  3284. <p><i>Effects:</i> Composes an absolute path from <code>p</code>, using the
  3285. same rules used by the operating system to resolve a path passed as the
  3286. filename argument to standard library open functions.</p>
  3287. <p><i>Returns:</i> The composed path.</p>
  3288. <p><i>Postcondition:</i> For the returned path, <code>rp,</code> <code>rp.is_absolute()</code> is true.</p>
  3289. <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
  3290. <p>[<i>Note:</i> For ISO/IEC 9945, <code>system_complete(p)</code> has the same semantics as <code>complete(p, current_path())</code>.</p>
  3291. <p><a name="windows_effects">For <i>Windows</i></a>, <code>system_complete(p)</code> has the
  3292. same semantics as <code>complete(ph, current_path())</code> if <code>p.is_absolute() || !p.has_root_name()</code> or <code>p</code> and <code>base</code> have the same <code>root_name()</code>.
  3293. Otherwise it acts like <code>complete(p, kinky)</code>, where <code>kinky</code> is the current directory for the <code>p.root_name()</code> drive. This will
  3294. be the current directory of that drive the last time it was set, and thus may
  3295. be <b>residue left over from a prior program</b> run by the command
  3296. processor! Although these semantics are often useful, they are also very
  3297. error-prone.</p>
  3298. <p>See <a href="#complete_note"><i>complete()</i> note</a> for usage suggestions. <i>—end note</i>]</p>
  3299. </blockquote>
  3300. <pre>path <a name="temp_directory_path">temp_directory_path</a>();
  3301. path temp_directory_path(system::error_code&amp; ec);</pre>
  3302. <blockquote>
  3303. <p><i>Returns:</i> A directory path suitable for temporary files under the
  3304. conventions of the operating system. The specifics of how this path is
  3305. determined are implementation defined. An error shall be reported if<code> !exists(p)
  3306. || !is_directory(p)</code>, where <code>p</code> is the path to be returned.</p>
  3307. <p>ISO/IEC 9945: The path supplied by the first environment variable found in the
  3308. list TMPDIR, TMP, TEMP, TEMPDIR. If none of these are found, <code>&quot;/tmp&quot;</code>,
  3309. or, if macro <code>__ANDROID__ </code>is defined, <code>&quot;/data/local/tmp&quot;</code>.</p>
  3310. <p><i>Windows:</i> The path reported by the <i>Windows</i> <code>GetTempPath</code> API function.</p>
  3311. <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
  3312. <p>[<i>Note: </i>The <code>temp_directory_path()</code> name was chosen to emphasize that the return is a
  3313. path, not just a single directory name.&nbsp; <i>—end note</i>]</p>
  3314. </blockquote>
  3315. <pre>path <a name="unique_path">unique_path</a>(const path&amp; model=&quot;%%%%-%%%%-%%%%-%%%%&quot;);
  3316. path unique_path(const path&amp; model, system::error_code&amp; ec);</pre>
  3317. <blockquote>
  3318. <p>The <code>unique_path</code> function generates a path name suitable for
  3319. creating temporary files, including directories. The name is based
  3320. on a model that uses the percent sign character to specify replacement by a
  3321. random hexadecimal digit. [<i>Note:</i> The more bits of randomness in the
  3322. generated path name, the less likelihood of prior existence or being guessed.
  3323. Each replacement hexadecimal digit in the model adds four bits of randomness.
  3324. The default model thus provides 64 bits of randomness. This is sufficient for
  3325. most applications. <i>—end note</i>]</p>
  3326. <p><i>Returns:</i> A path identical to <code>model</code>, except that each
  3327. occurrence of a percent sign character is replaced by a random hexadecimal
  3328. digit character in the range 0-9, a-f.</p>
  3329. <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
  3330. <p><i>Remarks:</i> Implementations are encouraged to obtain the required
  3331. randomness via a <a href="http://en.wikipedia.org/wiki/Cryptographically_secure_pseudorandom_number_generator">cryptographically secure pseudo-random number generator</a>, such as one
  3332. provided by the operating system. [<i>Note</i>: Such generators may block
  3333. until sufficient entropy develops. <i>—end note</i>]</p>
  3334. </blockquote>
  3335. <pre>path <a name="weakly_canonical">weakly_canonical</a>(const path&amp; p);
  3336. path weakly_canonical(const path&amp; p, system::error_code&amp; ec);</pre>
  3337. <blockquote>
  3338. <p><i>Overview:</i> Returns <code>p</code> with symlinks resolved and the
  3339. result normalized.</p>
  3340. <p><i>Returns: </i>A path composed of the result of calling the <code>
  3341. canonical</code> function on a path composed of the leading elements of <code>
  3342. p</code> that exist, if any, followed by the elements of <code>p</code> that
  3343. do not exist, if any.</p>
  3344. <p><i>Postcondition:</i> The returned path is in
  3345. <a href="#normal-form">
  3346. normal form</a>.</p>
  3347. <p><i>Remarks:</i> Uses <code>operator/=</code> to compose the returned path.
  3348. Uses the <code>status</code> function to determine existence.</p>
  3349. <p><i>Remarks:</i> Implementations are encouraged to avoid unnecessary
  3350. normalization such as when <code>canonical</code> has already been called on
  3351. the entirety of <code>p</code>.</p>
  3352. <p><i>Throws:</i>&nbsp; As specified in Error reporting.</p>
  3353. </blockquote>
  3354. <hr>
  3355. <!-- generate-section-numbers=false -->
  3356. <h3><a name="File-streams">File streams</a> -
  3357. <a href="../../../boost/filesystem/fstream.hpp">&lt;boost/filesystem/fstream.hpp&gt;</a></h3>
  3358. <p>Replacements are provided for the file stream classes from the C++ standard
  3359. library's <code>&lt;fstream&gt;</code> header. These replacement classes
  3360. publicly inherit from the standard library classes. In the Boost.Filesystem
  3361. version, constructors and open functions take <code>const path&amp;</code> arguments
  3362. instead of <code>
  3363. const char*</code> arguments. There are no other differences in syntax or
  3364. semantics.</p>
  3365. <pre>namespace boost
  3366. {
  3367. namespace filesystem
  3368. {
  3369. template &lt; class charT, class traits = std::char_traits&lt;charT&gt; &gt;
  3370. class basic_filebuf : public std::basic_filebuf&lt;charT,traits&gt;
  3371. {
  3372. public:
  3373. basic_filebuf&lt;charT,traits&gt;*
  3374. open(const path&amp; p, std::ios_base::openmode mode);
  3375. };
  3376. template &lt; class charT, class traits = std::char_traits&lt;charT&gt; &gt;
  3377. class basic_ifstream : public std::basic_ifstream&lt;charT,traits&gt;
  3378. {
  3379. public:
  3380. explicit basic_ifstream(const path&amp; p, std::ios_base::openmode mode=std::ios_base::in)
  3381. void open(const path&amp; p, std::ios_base::openmode mode=std::ios_base::in);
  3382. };
  3383. template &lt; class charT, class traits = std::char_traits&lt;charT&gt; &gt;
  3384. class basic_ofstream : public std::basic_ofstream&lt;charT,traits&gt;
  3385. {
  3386. public:
  3387. explicit basic_ofstream(const path&amp; p, std::ios_base::openmode mode=std::ios_base::out);
  3388. void open(const path&amp; p, std::ios_base::openmode mode=std::ios_base::out);
  3389. };
  3390. template &lt; class charT, class traits = std::char_traits&lt;charT&gt; &gt;
  3391. class basic_fstream : public std::basic_fstream&lt;charT,traits&gt;
  3392. {
  3393. public:
  3394. explicit basic_fstream(const path&amp; p,
  3395. std::ios_base::openmode mode=std::ios_base::in | std::ios_base::out);
  3396. void open(const path&amp; p,
  3397. std::ios_base::openmode mode=std::ios_base::in | std::ios_base::out);
  3398. };
  3399. typedef basic_filebuf&lt;char&gt; filebuf;
  3400. typedef basic_ifstream&lt;char&gt; ifstream;
  3401. typedef basic_ofstream&lt;char&gt; ofstream;
  3402. typedef basic_fstream&lt;char&gt; fstream;
  3403. typedef basic_filebuf&lt;wchar_t&gt; wfilebuf;
  3404. typedef basic_ifstream&lt;wchar_t&gt; wifstream;
  3405. typedef basic_fstream&lt;wchar_t&gt; wfstream;
  3406. typedef basic_ofstream&lt;wchar_t&gt; wofstream;
  3407. } // namespace filesystem
  3408. } // namespace boost</pre>
  3409. <h2><a name="path-decomposition-table">Path decomposition table</a></h2>
  3410. <p>The table is generated by a program compiled with the Boost implementation.</p>
  3411. <p>Shaded entries indicate cases where ISO/IEC 9945 (POSIX) and Windows implementations yield different results. The top value is the
  3412. ISO/IEC 9945 result and the bottom value is the Windows result. <br>
  3413. <table border="1" cellspacing="0" cellpadding="5">
  3414. <p>
  3415. <tr><td><b>Constructor<br>argument</b></td>
  3416. <td><b>Iteration<br>over<br>Elements</b></td>
  3417. <td><b><code>string()</code></b></td>
  3418. <td><b><code>generic_<br>string()</code></b></td>
  3419. <td><b><code>root_<br>path()</code></b></td>
  3420. <td><b><code>root_<br>name()</code></b></td>
  3421. <td><b><code>root_<br>directory()</code></b></td>
  3422. <td><b><code>relative_<br>path()</code></b></td>
  3423. <td><b><code>parent_<br>path()</code></b></td>
  3424. <td><b><code>filename()</code></b></td>
  3425. </tr>
  3426. <tr>
  3427. <td><font size="-1"><i>empty</i></font></td>
  3428. <td><font size="-1"><i>empty</i></font></td>
  3429. <td><font size="-1"><i>empty</i></font></td>
  3430. <td><font size="-1"><i>empty</i></font></td>
  3431. <td><font size="-1"><i>empty</i></font></td>
  3432. <td><font size="-1"><i>empty</i></font></td>
  3433. <td><font size="-1"><i>empty</i></font></td>
  3434. <td><font size="-1"><i>empty</i></font></td>
  3435. <td><font size="-1"><i>empty</i></font></td>
  3436. <td><font size="-1"><i>empty</i></font></td>
  3437. </tr>
  3438. <tr>
  3439. <td><code>.</code></td>
  3440. <td><code>.</code></td>
  3441. <td><code>.</code></td>
  3442. <td><code>.</code></td>
  3443. <td><font size="-1"><i>empty</i></font></td>
  3444. <td><font size="-1"><i>empty</i></font></td>
  3445. <td><font size="-1"><i>empty</i></font></td>
  3446. <td><code>.</code></td>
  3447. <td><font size="-1"><i>empty</i></font></td>
  3448. <td><code>.</code></td>
  3449. </tr>
  3450. <tr>
  3451. <td><code>..</code></td>
  3452. <td><code>..</code></td>
  3453. <td><code>..</code></td>
  3454. <td><code>..</code></td>
  3455. <td><font size="-1"><i>empty</i></font></td>
  3456. <td><font size="-1"><i>empty</i></font></td>
  3457. <td><font size="-1"><i>empty</i></font></td>
  3458. <td><code>..</code></td>
  3459. <td><font size="-1"><i>empty</i></font></td>
  3460. <td><code>..</code></td>
  3461. </tr>
  3462. <tr>
  3463. <td><code>foo</code></td>
  3464. <td><code>foo</code></td>
  3465. <td><code>foo</code></td>
  3466. <td><code>foo</code></td>
  3467. <td><font size="-1"><i>empty</i></font></td>
  3468. <td><font size="-1"><i>empty</i></font></td>
  3469. <td><font size="-1"><i>empty</i></font></td>
  3470. <td><code>foo</code></td>
  3471. <td><font size="-1"><i>empty</i></font></td>
  3472. <td><code>foo</code></td>
  3473. </tr>
  3474. <tr>
  3475. <td><code>/</code></td>
  3476. <td><code>/</code></td>
  3477. <td><code>/</code></td>
  3478. <td><code>/</code></td>
  3479. <td><code>/</code></td>
  3480. <td><font size="-1"><i>empty</i></font></td>
  3481. <td><code>/</code></td>
  3482. <td><font size="-1"><i>empty</i></font></td>
  3483. <td><font size="-1"><i>empty</i></font></td>
  3484. <td><code>/</code></td>
  3485. </tr>
  3486. <tr>
  3487. <td><code>/foo</code></td>
  3488. <td><code>/,foo</code></td>
  3489. <td><code>/foo</code></td>
  3490. <td><code>/foo</code></td>
  3491. <td><code>/</code></td>
  3492. <td><font size="-1"><i>empty</i></font></td>
  3493. <td><code>/</code></td>
  3494. <td><code>foo</code></td>
  3495. <td><code>/</code></td>
  3496. <td><code>foo</code></td>
  3497. </tr>
  3498. <tr>
  3499. <td><code>foo/</code></td>
  3500. <td><code>foo,.</code></td>
  3501. <td><code>foo/</code></td>
  3502. <td><code>foo/</code></td>
  3503. <td><font size="-1"><i>empty</i></font></td>
  3504. <td><font size="-1"><i>empty</i></font></td>
  3505. <td><font size="-1"><i>empty</i></font></td>
  3506. <td><code>foo/</code></td>
  3507. <td><code>foo</code></td>
  3508. <td><code>.</code></td>
  3509. </tr>
  3510. <tr>
  3511. <td><code>/foo/</code></td>
  3512. <td><code>/,foo,.</code></td>
  3513. <td><code>/foo/</code></td>
  3514. <td><code>/foo/</code></td>
  3515. <td><code>/</code></td>
  3516. <td><font size="-1"><i>empty</i></font></td>
  3517. <td><code>/</code></td>
  3518. <td><code>foo/</code></td>
  3519. <td><code>/foo</code></td>
  3520. <td><code>.</code></td>
  3521. </tr>
  3522. <tr>
  3523. <td><code>foo/bar</code></td>
  3524. <td><code>foo,bar</code></td>
  3525. <td><code>foo/bar</code></td>
  3526. <td><code>foo/bar</code></td>
  3527. <td><font size="-1"><i>empty</i></font></td>
  3528. <td><font size="-1"><i>empty</i></font></td>
  3529. <td><font size="-1"><i>empty</i></font></td>
  3530. <td><code>foo/bar</code></td>
  3531. <td><code>foo</code></td>
  3532. <td><code>bar</code></td>
  3533. </tr>
  3534. <tr>
  3535. <td><code>/foo/bar</code></td>
  3536. <td><code>/,foo,bar</code></td>
  3537. <td><code>/foo/bar</code></td>
  3538. <td><code>/foo/bar</code></td>
  3539. <td><code>/</code></td>
  3540. <td><font size="-1"><i>empty</i></font></td>
  3541. <td><code>/</code></td>
  3542. <td><code>foo/bar</code></td>
  3543. <td><code>/foo</code></td>
  3544. <td><code>bar</code></td>
  3545. </tr>
  3546. <tr>
  3547. <td><code>//net</code></td>
  3548. <td><code>//net</code></td>
  3549. <td><code>//net</code></td>
  3550. <td><code>//net</code></td>
  3551. <td><code>//net</code></td>
  3552. <td><code>//net</code></td>
  3553. <td><font size="-1"><i>empty</i></font></td>
  3554. <td><font size="-1"><i>empty</i></font></td>
  3555. <td><font size="-1"><i>empty</i></font></td>
  3556. <td><code>//net</code></td>
  3557. </tr>
  3558. <tr>
  3559. <td><code>//net/foo</code></td>
  3560. <td><code>//net,/,foo</code></td>
  3561. <td><code>//net/foo</code></td>
  3562. <td><code>//net/foo</code></td>
  3563. <td><code>//net/</code></td>
  3564. <td><code>//net</code></td>
  3565. <td><code>/</code></td>
  3566. <td><code>foo</code></td>
  3567. <td><code>//net/</code></td>
  3568. <td><code>foo</code></td>
  3569. </tr>
  3570. <tr>
  3571. <td><code>///foo///</code></td>
  3572. <td><code>/,foo,.</code></td>
  3573. <td><code>///foo///</code></td>
  3574. <td><code>///foo///</code></td>
  3575. <td><code>/</code></td>
  3576. <td><font size="-1"><i>empty</i></font></td>
  3577. <td><code>/</code></td>
  3578. <td><code>foo///</code></td>
  3579. <td><code>///foo</code></td>
  3580. <td><code>.</code></td>
  3581. </tr>
  3582. <tr>
  3583. <td><code>///foo///bar</code></td>
  3584. <td><code>/,foo,bar</code></td>
  3585. <td><code>///foo///bar</code></td>
  3586. <td><code>///foo///bar</code></td>
  3587. <td><code>/</code></td>
  3588. <td><font size="-1"><i>empty</i></font></td>
  3589. <td><code>/</code></td>
  3590. <td><code>foo///bar</code></td>
  3591. <td><code>///foo</code></td>
  3592. <td><code>bar</code></td>
  3593. </tr>
  3594. <tr>
  3595. <td><code>/.</code></td>
  3596. <td><code>/,.</code></td>
  3597. <td><code>/.</code></td>
  3598. <td><code>/.</code></td>
  3599. <td><code>/</code></td>
  3600. <td><font size="-1"><i>empty</i></font></td>
  3601. <td><code>/</code></td>
  3602. <td><code>.</code></td>
  3603. <td><code>/</code></td>
  3604. <td><code>.</code></td>
  3605. </tr>
  3606. <tr>
  3607. <td><code>./</code></td>
  3608. <td><code>.,.</code></td>
  3609. <td><code>./</code></td>
  3610. <td><code>./</code></td>
  3611. <td><font size="-1"><i>empty</i></font></td>
  3612. <td><font size="-1"><i>empty</i></font></td>
  3613. <td><font size="-1"><i>empty</i></font></td>
  3614. <td><code>./</code></td>
  3615. <td><code>.</code></td>
  3616. <td><code>.</code></td>
  3617. </tr>
  3618. <tr>
  3619. <td><code>/..</code></td>
  3620. <td><code>/,..</code></td>
  3621. <td><code>/..</code></td>
  3622. <td><code>/..</code></td>
  3623. <td><code>/</code></td>
  3624. <td><font size="-1"><i>empty</i></font></td>
  3625. <td><code>/</code></td>
  3626. <td><code>..</code></td>
  3627. <td><code>/</code></td>
  3628. <td><code>..</code></td>
  3629. </tr>
  3630. <tr>
  3631. <td><code>../</code></td>
  3632. <td><code>..,.</code></td>
  3633. <td><code>../</code></td>
  3634. <td><code>../</code></td>
  3635. <td><font size="-1"><i>empty</i></font></td>
  3636. <td><font size="-1"><i>empty</i></font></td>
  3637. <td><font size="-1"><i>empty</i></font></td>
  3638. <td><code>../</code></td>
  3639. <td><code>..</code></td>
  3640. <td><code>.</code></td>
  3641. </tr>
  3642. <tr>
  3643. <td><code>foo/.</code></td>
  3644. <td><code>foo,.</code></td>
  3645. <td><code>foo/.</code></td>
  3646. <td><code>foo/.</code></td>
  3647. <td><font size="-1"><i>empty</i></font></td>
  3648. <td><font size="-1"><i>empty</i></font></td>
  3649. <td><font size="-1"><i>empty</i></font></td>
  3650. <td><code>foo/.</code></td>
  3651. <td><code>foo</code></td>
  3652. <td><code>.</code></td>
  3653. </tr>
  3654. <tr>
  3655. <td><code>foo/..</code></td>
  3656. <td><code>foo,..</code></td>
  3657. <td><code>foo/..</code></td>
  3658. <td><code>foo/..</code></td>
  3659. <td><font size="-1"><i>empty</i></font></td>
  3660. <td><font size="-1"><i>empty</i></font></td>
  3661. <td><font size="-1"><i>empty</i></font></td>
  3662. <td><code>foo/..</code></td>
  3663. <td><code>foo</code></td>
  3664. <td><code>..</code></td>
  3665. </tr>
  3666. <tr>
  3667. <td><code>foo/./</code></td>
  3668. <td><code>foo,.,.</code></td>
  3669. <td><code>foo/./</code></td>
  3670. <td><code>foo/./</code></td>
  3671. <td><font size="-1"><i>empty</i></font></td>
  3672. <td><font size="-1"><i>empty</i></font></td>
  3673. <td><font size="-1"><i>empty</i></font></td>
  3674. <td><code>foo/./</code></td>
  3675. <td><code>foo/.</code></td>
  3676. <td><code>.</code></td>
  3677. </tr>
  3678. <tr>
  3679. <td><code>foo/./bar</code></td>
  3680. <td><code>foo,.,bar</code></td>
  3681. <td><code>foo/./bar</code></td>
  3682. <td><code>foo/./bar</code></td>
  3683. <td><font size="-1"><i>empty</i></font></td>
  3684. <td><font size="-1"><i>empty</i></font></td>
  3685. <td><font size="-1"><i>empty</i></font></td>
  3686. <td><code>foo/./bar</code></td>
  3687. <td><code>foo/.</code></td>
  3688. <td><code>bar</code></td>
  3689. </tr>
  3690. <tr>
  3691. <td><code>foo/..</code></td>
  3692. <td><code>foo,..</code></td>
  3693. <td><code>foo/..</code></td>
  3694. <td><code>foo/..</code></td>
  3695. <td><font size="-1"><i>empty</i></font></td>
  3696. <td><font size="-1"><i>empty</i></font></td>
  3697. <td><font size="-1"><i>empty</i></font></td>
  3698. <td><code>foo/..</code></td>
  3699. <td><code>foo</code></td>
  3700. <td><code>..</code></td>
  3701. </tr>
  3702. <tr>
  3703. <td><code>foo/../</code></td>
  3704. <td><code>foo,..,.</code></td>
  3705. <td><code>foo/../</code></td>
  3706. <td><code>foo/../</code></td>
  3707. <td><font size="-1"><i>empty</i></font></td>
  3708. <td><font size="-1"><i>empty</i></font></td>
  3709. <td><font size="-1"><i>empty</i></font></td>
  3710. <td><code>foo/../</code></td>
  3711. <td><code>foo/..</code></td>
  3712. <td><code>.</code></td>
  3713. </tr>
  3714. <tr>
  3715. <td><code>foo/../bar</code></td>
  3716. <td><code>foo,..,bar</code></td>
  3717. <td><code>foo/../bar</code></td>
  3718. <td><code>foo/../bar</code></td>
  3719. <td><font size="-1"><i>empty</i></font></td>
  3720. <td><font size="-1"><i>empty</i></font></td>
  3721. <td><font size="-1"><i>empty</i></font></td>
  3722. <td><code>foo/../bar</code></td>
  3723. <td><code>foo/..</code></td>
  3724. <td><code>bar</code></td>
  3725. </tr>
  3726. <tr>
  3727. <td><code>c:</code></td>
  3728. <td><code>c:</code></td>
  3729. <td><code>c:</code></td>
  3730. <td><code>c:</code></td>
  3731. <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
  3732. <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
  3733. <td><font size="-1"><i>empty</i></font></td>
  3734. <td><code>c:</code><br><font size="-1"><i>empty</i></font></td>
  3735. <td><font size="-1"><i>empty</i></font></td>
  3736. <td><code>c:</code></td>
  3737. </tr>
  3738. <tr>
  3739. <td><code>c:/</code></td>
  3740. <td><code>c:,.</code><br><code>c:,/</code></td>
  3741. <td><code>c:/</code></td>
  3742. <td><code>c:/</code></td>
  3743. <td><font size="-1"><i>empty</i></font><br><code>c:/</code></td>
  3744. <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
  3745. <td><font size="-1"><i>empty</i></font><br><code>/</code></td>
  3746. <td><code>c:/</code><br><font size="-1"><i>empty</i></font></td>
  3747. <td><code>c:</code></td>
  3748. <td><code>.</code><br><code>/</code></td>
  3749. </tr>
  3750. <tr>
  3751. <td><code>c:foo</code></td>
  3752. <td><code>c:foo</code><br><code>c:,foo</code></td>
  3753. <td><code>c:foo</code></td>
  3754. <td><code>c:foo</code></td>
  3755. <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
  3756. <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
  3757. <td><font size="-1"><i>empty</i></font></td>
  3758. <td><code>c:foo</code><br><code>foo</code></td>
  3759. <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
  3760. <td><code>c:foo</code><br><code>foo</code></td>
  3761. </tr>
  3762. <tr>
  3763. <td><code>c:/foo</code></td>
  3764. <td><code>c:,foo</code><br><code>c:,/,foo</code></td>
  3765. <td><code>c:/foo</code></td>
  3766. <td><code>c:/foo</code></td>
  3767. <td><font size="-1"><i>empty</i></font><br><code>c:/</code></td>
  3768. <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
  3769. <td><font size="-1"><i>empty</i></font><br><code>/</code></td>
  3770. <td><code>c:/foo</code><br><code>foo</code></td>
  3771. <td><code>c:</code><br><code>c:/</code></td>
  3772. <td><code>foo</code></td>
  3773. </tr>
  3774. <tr>
  3775. <td><code>c:foo/</code></td>
  3776. <td><code>c:foo,.</code><br><code>c:,foo,.</code></td>
  3777. <td><code>c:foo/</code></td>
  3778. <td><code>c:foo/</code></td>
  3779. <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
  3780. <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
  3781. <td><font size="-1"><i>empty</i></font></td>
  3782. <td><code>c:foo/</code><br><code>foo/</code></td>
  3783. <td><code>c:foo</code></td>
  3784. <td><code>.</code></td>
  3785. </tr>
  3786. <tr>
  3787. <td><code>c:/foo/</code></td>
  3788. <td><code>c:,foo,.</code><br><code>c:,/,foo,.</code></td>
  3789. <td><code>c:/foo/</code></td>
  3790. <td><code>c:/foo/</code></td>
  3791. <td><font size="-1"><i>empty</i></font><br><code>c:/</code></td>
  3792. <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
  3793. <td><font size="-1"><i>empty</i></font><br><code>/</code></td>
  3794. <td><code>c:/foo/</code><br><code>foo/</code></td>
  3795. <td><code>c:/foo</code></td>
  3796. <td><code>.</code></td>
  3797. </tr>
  3798. <tr>
  3799. <td><code>c:/foo/bar</code></td>
  3800. <td><code>c:,foo,bar</code><br><code>c:,/,foo,bar</code></td>
  3801. <td><code>c:/foo/bar</code></td>
  3802. <td><code>c:/foo/bar</code></td>
  3803. <td><font size="-1"><i>empty</i></font><br><code>c:/</code></td>
  3804. <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
  3805. <td><font size="-1"><i>empty</i></font><br><code>/</code></td>
  3806. <td><code>c:/foo/bar</code><br><code>foo/bar</code></td>
  3807. <td><code>c:/foo</code></td>
  3808. <td><code>bar</code></td>
  3809. </tr>
  3810. <tr>
  3811. <td><code>prn:</code></td>
  3812. <td><code>prn:</code></td>
  3813. <td><code>prn:</code></td>
  3814. <td><code>prn:</code></td>
  3815. <td><font size="-1"><i>empty</i></font><br><code>prn:</code></td>
  3816. <td><font size="-1"><i>empty</i></font><br><code>prn:</code></td>
  3817. <td><font size="-1"><i>empty</i></font></td>
  3818. <td><code>prn:</code><br><font size="-1"><i>empty</i></font></td>
  3819. <td><font size="-1"><i>empty</i></font></td>
  3820. <td><code>prn:</code></td>
  3821. </tr>
  3822. <tr>
  3823. <td><code>c:\</code></td>
  3824. <td><code>c:\</code><br><code>c:,/</code></td>
  3825. <td><code>c:\</code></td>
  3826. <td><code>c:\</code><br><code>c:/</code></td>
  3827. <td><font size="-1"><i>empty</i></font><br><code>c:\</code></td>
  3828. <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
  3829. <td><font size="-1"><i>empty</i></font><br><code>\</code></td>
  3830. <td><code>c:\</code><br><font size="-1"><i>empty</i></font></td>
  3831. <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
  3832. <td><code>c:\</code><br><code>\</code></td>
  3833. </tr>
  3834. <tr>
  3835. <td><code>c:foo</code></td>
  3836. <td><code>c:foo</code><br><code>c:,foo</code></td>
  3837. <td><code>c:foo</code></td>
  3838. <td><code>c:foo</code></td>
  3839. <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
  3840. <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
  3841. <td><font size="-1"><i>empty</i></font></td>
  3842. <td><code>c:foo</code><br><code>foo</code></td>
  3843. <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
  3844. <td><code>c:foo</code><br><code>foo</code></td>
  3845. </tr>
  3846. <tr>
  3847. <td><code>c:\foo</code></td>
  3848. <td><code>c:\foo</code><br><code>c:,/,foo</code></td>
  3849. <td><code>c:\foo</code></td>
  3850. <td><code>c:\foo</code><br><code>c:/foo</code></td>
  3851. <td><font size="-1"><i>empty</i></font><br><code>c:\</code></td>
  3852. <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
  3853. <td><font size="-1"><i>empty</i></font><br><code>\</code></td>
  3854. <td><code>c:\foo</code><br><code>foo</code></td>
  3855. <td><font size="-1"><i>empty</i></font><br><code>c:\</code></td>
  3856. <td><code>c:\foo</code><br><code>foo</code></td>
  3857. </tr>
  3858. <tr>
  3859. <td><code>c:foo\</code></td>
  3860. <td><code>c:foo\</code><br><code>c:,foo,.</code></td>
  3861. <td><code>c:foo\</code></td>
  3862. <td><code>c:foo\</code><br><code>c:foo/</code></td>
  3863. <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
  3864. <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
  3865. <td><font size="-1"><i>empty</i></font></td>
  3866. <td><code>c:foo\</code><br><code>foo\</code></td>
  3867. <td><font size="-1"><i>empty</i></font><br><code>c:foo</code></td>
  3868. <td><code>c:foo\</code><br><code>.</code></td>
  3869. </tr>
  3870. <tr>
  3871. <td><code>c:\foo\</code></td>
  3872. <td><code>c:\foo\</code><br><code>c:,/,foo,.</code></td>
  3873. <td><code>c:\foo\</code></td>
  3874. <td><code>c:\foo\</code><br><code>c:/foo/</code></td>
  3875. <td><font size="-1"><i>empty</i></font><br><code>c:\</code></td>
  3876. <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
  3877. <td><font size="-1"><i>empty</i></font><br><code>\</code></td>
  3878. <td><code>c:\foo\</code><br><code>foo\</code></td>
  3879. <td><font size="-1"><i>empty</i></font><br><code>c:\foo</code></td>
  3880. <td><code>c:\foo\</code><br><code>.</code></td>
  3881. </tr>
  3882. <tr>
  3883. <td><code>c:\foo/</code></td>
  3884. <td><code>c:\foo,.</code><br><code>c:,/,foo,.</code></td>
  3885. <td><code>c:\foo/</code></td>
  3886. <td><code>c:\foo/</code><br><code>c:/foo/</code></td>
  3887. <td><font size="-1"><i>empty</i></font><br><code>c:\</code></td>
  3888. <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
  3889. <td><font size="-1"><i>empty</i></font><br><code>\</code></td>
  3890. <td><code>c:\foo/</code><br><code>foo/</code></td>
  3891. <td><code>c:\foo</code></td>
  3892. <td><code>.</code></td>
  3893. </tr>
  3894. <tr>
  3895. <td><code>c:/foo\bar</code></td>
  3896. <td><code>c:,foo\bar</code><br><code>c:,/,foo,bar</code></td>
  3897. <td><code>c:/foo\bar</code></td>
  3898. <td><code>c:/foo\bar</code><br><code>c:/foo/bar</code></td>
  3899. <td><font size="-1"><i>empty</i></font><br><code>c:/</code></td>
  3900. <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
  3901. <td><font size="-1"><i>empty</i></font><br><code>/</code></td>
  3902. <td><code>c:/foo\bar</code><br><code>foo\bar</code></td>
  3903. <td><code>c:</code><br><code>c:/foo</code></td>
  3904. <td><code>foo\bar</code><br><code>bar</code></td>
  3905. </tr>
  3906. </table>
  3907. <h2><a name="long-path-warning"></a>Warning: Long paths on Windows and the
  3908. extended-length <b>\\?\ </b>prefix</h2>
  3909. <p>The Microsoft Windows &quot;Maximum Path Length Limitation&quot; specifies:</p>
  3910. <blockquote>
  3911. <p>In the Windows API (with some exceptions ...), the maximum length for a path
  3912. is MAX_PATH, which is defined as 260 characters.</p>
  3913. <p>The Windows API has many functions that also have Unicode versions to permit
  3914. an extended-length path for a maximum total path length of 32,767 characters.
  3915. ... To specify an extended-length path, use the <b>&quot;\\?\&quot; prefix</b>. For
  3916. example, &quot;\\?\D:\<em>very long path</em>&quot;.&nbsp; <i>[C++ string literals require backslashes be doubled, of course.]</i></p>
  3917. </blockquote>
  3918. <p>Because most Boost.Filesystem operational functions just pass the contents of
  3919. a class path object to the Windows API, they do work with the extended-length
  3920. prefixes. But some won't work, because to the limitations imposed by Windows.
  3921. Read the following cautions carefully!</p>
  3922. <h3>Cautions for paths with extended-length prefixes</h3>
  3923. <ul>
  3924. <li>Individual components of a path are still are limited to whatever is
  3925. supported for the particular filesystem, commonly 255 characters.</li>
  3926. <li>Only backslashes are acceptable as directory separators. Slashes are
  3927. not treated as separators.</li>
  3928. <li>All paths must be absolute - relative paths are not allowed.</li>
  3929. <li>Once an absolute path grows beyond 260 characters, it is essentially
  3930. poisoned and all operations must use extended-length prefixes. So even a
  3931. simple operation like <code>create_directory(&quot;a&quot;)</code> will fail if the
  3932. absolute path of the resulting directory would exceed 260 characters.</li>
  3933. <li>Certain Boost.Filesystem functions that decompose their argument path and
  3934. then work on individual relative directories or files will not work properly
  3935. with extended-length prefix paths.</li>
  3936. </ul>
  3937. <h2><a name="Acknowledgements">Acknowledgements</a></h2>
  3938. <p>This Filesystem Library is dedicated to my wife, Sonda, who provided the
  3939. support necessary to see both a trial implementation and the proposal itself
  3940. through to completion. She gave me the strength to continue after a difficult
  3941. year of cancer treatment in the middle of it all.</p>
  3942. <p>Many people contributed technical comments, ideas, and suggestions to the
  3943. Boost Filesystem Library. See <a href="http://www.boost.org/libs/filesystem/doc/index.htm#Acknowledgements">http://www.boost.org/libs/filesystem/doc/index.htm#Acknowledgements</a>.</p>
  3944. <p>Dietmar Kuehl contributed the original Boost Filesystem Library directory_iterator design. Peter Dimov, Walter Landry, Rob Stewart, and Thomas
  3945. Witt were particularly helpful in refining the library.</p>
  3946. <p>The create_directories, extension, basename, and replace_extension functions
  3947. were developed by Vladimir Prus. The temp_directory_path function was
  3948. contributed by Jeff Flinn. David Svoboda suggested the canonical function and
  3949. provided pseudo-code.</p>
  3950. <p>Howard Hinnant and John Maddock reviewed a draft of the version 2 proposal, and
  3951. identified a number of mistakes or weaknesses, resulting in a more polished
  3952. final document.</p>
  3953. <p>Peter Dimov suggested a single class path, with member templates to adapt to
  3954. multiple string types. His idea became the basis for the version 3 path design.</p>
  3955. <h2><a name="References">References</a></h2>
  3956. <table border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
  3957. <tr>
  3958. <td width="16%" valign="top">[<a name="ISO_POSIX">ISO/IEC 9945</a>]</td>
  3959. <td width="84%">ISO/IEC 9945:2003, IEEE&nbsp;Std&nbsp;1003.1-2001, and The Open Group
  3960. Base Specifications, Issue 6. Also known as The Single Unix<font face="Times New Roman">&reg;
  3961. Specification, Version 3. Available from each of the organizations involved
  3962. in its creation. For example, read online or download from <a href="http://www.unix.org/single_unix_specification/">www.unix.org/single_unix_specification/</a>.</font> The ISO JTC1/SC22/WG15 -
  3963. POSIX homepage is <a href="http://www.open-std.org/jtc1/sc22/WG15/">www.open-std.org/jtc1/sc22/WG15/</a></td>
  3964. </tr>
  3965. <tr>
  3966. <td width="16%" valign="top">[Abrahams]</td>
  3967. <td width="84%">Dave Abrahams, Error and Exception Handling, <a href="http://www.boost.org/more/error_handling.html">www.boost.org/more/error_handling.html</a></td>
  3968. </tr>
  3969. </table>
  3970. <hr>
  3971. <p><font size="2">&copy; Copyright Beman Dawes, 2002, 2006, 2007, 2009, 2010, 2011</font></p>
  3972. <p><font size="2">Distributed under the Boost Software License, Version 1.0. See
  3973. </font>
  3974. <a href="http://www.boost.org/LICENSE_1_0.txt"><font size="2">www.boost.org/LICENSE_1_0.txt</font></a></p>
  3975. <p><font size="2">Revised
  3976. <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B %Y" startspan -->01 December 2015<!--webbot bot="Timestamp" endspan i-checksum="39286" --></font></p>
  3977. </body>
  3978. </html>