index.html 167 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547
<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>
<html lang="en" dir="ltr">
<head>
    <title>File API: Directories and System</title>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
    
    
  <link href="respec.css" rel="stylesheet" type="text/css" charset="utf-8"><link href="http://www.w3.org/StyleSheets/TR/W3C-WD" rel="stylesheet" type="text/css" charset="utf-8"></head>
  <body style="display: inherit; "><div class="head"><p><a href="http://www.w3.org/"><img width="72" height="48" src="http://www.w3.org/Icons/w3c_home" alt="W3C"></a></p><h1 class="title" id="title">File API: Directories and System</h1><h2 id="w3c-working-draft-19-april-2011">W3C Working Draft 19 April 2011</h2><dl><dt>This version:</dt><dd><a href="http://www.w3.org/TR/2011/WD-file-system-api-20110419/">http://www.w3.org/TR/2011/WD-file-system-api-20110419/</a></dd><dt>Latest published version:</dt><dd><a href="http://www.w3.org/TR/file-system-api/">http://www.w3.org/TR/file-system-api/</a></dd><dt>Latest editor's draft:</dt><dd><a href="http://dev.w3.org/2009/dap/file-system/file-dir-sys.html">http://dev.w3.org/2009/dap/file-system/file-dir-sys.html</a></dd>
<dt>Previous version:</dt>
<dd><a href="http://www.w3.org/TR/2010/WD-file-system-api-20101026/">http://www.w3.org/TR/2010/WD-file-system-api-20101026/</a>
</dd><dt>Editor:</dt><dd><a href="http://www.ofb.net/~uranium/">Eric Uhrhane</a>, <a href="http://www.google.com/">Google</a></dd>
</dl><p class="copyright"><a
href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a>
&copy; 2011 <a href="http://www.w3.org/"><acronym title="World Wide Web
Consortium">W3C</acronym></a><sup>&reg;</sup> (<a href="http://www.csail.mit.edu/"><acronym title="Massachusetts Institute of Technology">MIT</acronym></a>, <a href="http://www.ercim.eu/"><acronym title="European Research Consortium for Informatics and Mathematics">ERCIM</acronym></a>, <a href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved. W3C <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>, <a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a> and <a href="http://www.w3.org/Consortium/Legal/copyright-documents">document use</a> rules apply.</p><hr></div>
    <div id="abstract" class="introductory section"><h2>Abstract</h2>
      This specification defines an <acronym title="Application Programming
      Interface">API</acronym> to navigate file system hierarchies, and defines
      a means by which a <a href="#dfn-user-agent" class="internalDFN">user agent</a> may expose sandboxed sections of a
      user's local filesystem to web applications.  It builds on
      [<cite><a class="bibref" rel="biblioentry" href="#bib-FILE-WRITER">FILE-WRITER</a></cite>], which in turn built on [<cite><a class="bibref" rel="biblioentry" href="#bib-FILE-API">FILE-API</a></cite>], each adding a
      different kind of functionality.
    </div><div id="sotd" class="introductory section"><h2>Status of This Document</h2><p><em>This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the <a href="http://www.w3.org/TR/">W3C technical reports index</a> at http://www.w3.org/TR/.</em></p><p>This document was published by the <a href="http://www.w3.org/2008/webapps/">WebApps Working Group</a> as a Working Draft. This document is intended to become a W3C Recommendation. If you wish to make comments regarding this document, please send them to <a href="mailto:public-webapps@w3.org">public-webapps@w3.org</a> (<a href="mailto:public-webapps-request@w3.org?subject=subscribe">subscribe</a>, <a href="http://lists.w3.org/Archives/Public/public-webapps/">archives</a>). All feedback is welcome.</p><p>Publication as a Working Draft does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.</p><p>This document was produced by a group operating under the <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February 2004 W3C Patent Policy</a>. W3C maintains a <a href="http://www.w3.org/2004/01/pp-impl/42538/status" rel="disclosure">public list of any patent disclosures</a> made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential Claim(s)</a> must disclose the information in accordance with <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section 6 of the W3C Patent Policy</a>.</p></div><div id="toc" class="section"><h2 class="introductory">Table of Contents</h2><ul class="toc"><li class="tocline"><a href="#conformance" class="tocxref"><span class="secno">1. </span>Conformance</a></li><li class="tocline"><a href="#introduction" class="tocxref"><span class="secno">2. </span>Introduction</a><ul class="toc"><li class="tocline"><a href="#use-cases" class="tocxref"><span class="secno">2.1 </span>Use Cases</a></li><li class="tocline"><a href="#examples" class="tocxref"><span class="secno">2.2 </span>Examples</a></li></ul></li><li class="tocline"><a href="#data-persistence-and-accessing-the-api" class="tocxref"><span class="secno">3. </span>Data Persistence and accessing the API</a><ul class="toc"><li class="tocline"><a href="#temporary-vs.-persistent-storage" class="tocxref"><span class="secno">3.1 </span>Temporary vs. Persistent Storage</a></li><li class="tocline"><a href="#restrictions" class="tocxref"><span class="secno">3.2 </span>Restrictions</a></li><li class="tocline"><a href="#security-considerations" class="tocxref"><span class="secno">3.3 </span>Security Considerations</a></li><li class="tocline"><a href="#obtaining-access-to-file-system-entry-points" class="tocxref"><span class="secno">3.4 </span>Obtaining access to file system entry points</a><ul class="toc"><li class="tocline"><a href="#using-localfilesystem" class="tocxref"><span class="secno">3.4.1 </span>Using <code>LocalFileSystem</code></a><ul class="toc"><li class="tocline"><a href="#methods" class="tocxref"><span class="secno">3.4.1.1 </span>Methods</a></li><li class="tocline"><a href="#constants" class="tocxref"><span class="secno">3.4.1.2 </span>Constants</a></li></ul></li><li class="tocline"><a href="#using-localfilesystemsync" class="tocxref"><span class="secno">3.4.2 </span>Using <code>LocalFileSystemSync</code></a><ul class="toc"><li class="tocline"><a href="#methods-1" class="tocxref"><span class="secno">3.4.2.1 </span>Methods</a></li><li class="tocline"><a href="#constants-1" class="tocxref"><span class="secno">3.4.2.2 </span>Constants</a></li></ul></li></ul></li></ul></li><li class="tocline"><a href="#shared-data-types" class="tocxref"><span class="secno">4. </span>Shared data types</a><ul class="toc"><li class="tocline"><a href="#the-metadata-interface" class="tocxref"><span class="secno">4.1 </span>The <code>Metadata</code> interface</a><ul class="toc"><li class="tocline"><a href="#attributes" class="tocxref"><span class="secno">4.1.1 </span>Attributes</a></li></ul></li><li class="tocline"><a href="#the-flags-interface" class="tocxref"><span class="secno">4.2 </span>The <code>Flags</code> interface</a><ul class="toc"><li class="tocline"><a href="#attributes-1" class="tocxref"><span class="secno">4.2.1 </span>Attributes</a></li><li class="tocline"><a href="#examples-1" class="tocxref"><span class="secno">4.2.2 </span>Examples</a></li></ul></li></ul></li><li class="tocline"><a href="#the-asynchronous-filesystem-interface" class="tocxref"><span class="secno">5. </span>The asynchronous filesystem interface</a><ul class="toc"><li class="tocline"><a href="#the-filesystem-interface" class="tocxref"><span class="secno">5.1 </span>The <code>FileSystem</code> interface</a><ul class="toc"><li class="tocline"><a href="#attributes-2" class="tocxref"><span class="secno">5.1.1 </span>Attributes</a></li></ul></li><li class="tocline"><a href="#the-entry-interface" class="tocxref"><span class="secno">5.2 </span>The <code>Entry</code> interface</a><ul class="toc"><li class="tocline"><a href="#attributes-3" class="tocxref"><span class="secno">5.2.1 </span>Attributes</a></li><li class="tocline"><a href="#methods-2" class="tocxref"><span class="secno">5.2.2 </span>Methods</a></li></ul></li><li class="tocline"><a href="#the-directoryentry-interface" class="tocxref"><span class="secno">5.3 </span>The <code>DirectoryEntry</code> interface</a><ul class="toc"><li class="tocline"><a href="#methods-3" class="tocxref"><span class="secno">5.3.1 </span>Methods</a></li></ul></li><li class="tocline"><a href="#the-directoryreader-interface" class="tocxref"><span class="secno">5.4 </span>The <code>DirectoryReader</code> interface</a><ul class="toc"><li class="tocline"><a href="#methods-4" class="tocxref"><span class="secno">5.4.1 </span>Methods</a></li></ul></li><li class="tocline"><a href="#the-fileentry-interface" class="tocxref"><span class="secno">5.5 </span>The <code>FileEntry</code> interface</a><ul class="toc"><li class="tocline"><a href="#methods-5" class="tocxref"><span class="secno">5.5.1 </span>Methods</a></li></ul></li><li class="tocline"><a href="#callbacks" class="tocxref"><span class="secno">5.6 </span>Callbacks</a><ul class="toc"><li class="tocline"><a href="#the-filesystemcallback-interface" class="tocxref"><span class="secno">5.6.1 </span>The <code>FileSystemCallback</code> interface</a><ul class="toc"><li class="tocline"><a href="#methods-6" class="tocxref"><span class="secno">5.6.1.1 </span>Methods</a></li></ul></li><li class="tocline"><a href="#the-entrycallback-interface" class="tocxref"><span class="secno">5.6.2 </span>The <code>EntryCallback</code> interface</a><ul class="toc"><li class="tocline"><a href="#methods-7" class="tocxref"><span class="secno">5.6.2.1 </span>Methods</a></li></ul></li><li class="tocline"><a href="#the-entriescallback-interface" class="tocxref"><span class="secno">5.6.3 </span>The <code>EntriesCallback</code> interface</a><ul class="toc"><li class="tocline"><a href="#methods-8" class="tocxref"><span class="secno">5.6.3.1 </span>Methods</a></li></ul></li><li class="tocline"><a href="#the-metadatacallback-interface" class="tocxref"><span class="secno">5.6.4 </span>The <code>MetadataCallback</code> interface</a><ul class="toc"><li class="tocline"><a href="#methods-9" class="tocxref"><span class="secno">5.6.4.1 </span>Methods</a></li></ul></li><li class="tocline"><a href="#the-filewritercallback-interface" class="tocxref"><span class="secno">5.6.5 </span>The <code>FileWriterCallback</code> interface</a><ul class="toc"><li class="tocline"><a href="#methods-10" class="tocxref"><span class="secno">5.6.5.1 </span>Methods</a></li></ul></li><li class="tocline"><a href="#the-filecallback-interface" class="tocxref"><span class="secno">5.6.6 </span>The <code>FileCallback</code> interface</a><ul class="toc"><li class="tocline"><a href="#methods-11" class="tocxref"><span class="secno">5.6.6.1 </span>Methods</a></li></ul></li><li class="tocline"><a href="#the-voidcallback-interface" class="tocxref"><span class="secno">5.6.7 </span>The <code>VoidCallback</code> interface</a><ul class="toc"><li class="tocline"><a href="#methods-12" class="tocxref"><span class="secno">5.6.7.1 </span>Methods</a></li></ul></li><li class="tocline"><a href="#the-errorcallback-interface" class="tocxref"><span class="secno">5.6.8 </span>The <code>ErrorCallback</code> interface</a><ul class="toc"><li class="tocline"><a href="#methods-13" class="tocxref"><span class="secno">5.6.8.1 </span>Methods</a></li></ul></li></ul></li></ul></li><li class="tocline"><a href="#the-synchronous-filesystem-interface" class="tocxref"><span class="secno">6. </span>The synchronous filesystem interface</a><ul class="toc"><li class="tocline"><a href="#the-filesystemsync-interface" class="tocxref"><span class="secno">6.1 </span>The <code>FileSystemSync</code> interface</a><ul class="toc"><li class="tocline"><a href="#attributes-4" class="tocxref"><span class="secno">6.1.1 </span>Attributes</a></li></ul></li><li class="tocline"><a href="#the-entrysync-interface" class="tocxref"><span class="secno">6.2 </span>The <code>EntrySync</code> interface</a><ul class="toc"><li class="tocline"><a href="#attributes-5" class="tocxref"><span class="secno">6.2.1 </span>Attributes</a></li><li class="tocline"><a href="#methods-14" class="tocxref"><span class="secno">6.2.2 </span>Methods</a></li></ul></li><li class="tocline"><a href="#the-directoryentrysync-interface" class="tocxref"><span class="secno">6.3 </span>The <code>DirectoryEntrySync</code> interface</a><ul class="toc"><li class="tocline"><a href="#methods-15" class="tocxref"><span class="secno">6.3.1 </span>Methods</a></li></ul></li><li class="tocline"><a href="#the-directoryreadersync-interface" class="tocxref"><span class="secno">6.4 </span>The <code>DirectoryReaderSync</code> interface</a><ul class="toc"><li class="tocline"><a href="#methods-16" class="tocxref"><span class="secno">6.4.1 </span>Methods</a></li></ul></li><li class="tocline"><a href="#the-fileentrysync-interface" class="tocxref"><span class="secno">6.5 </span>The <code>FileEntrySync</code> interface</a><ul class="toc"><li class="tocline"><a href="#methods-17" class="tocxref"><span class="secno">6.5.1 </span>Methods</a></li></ul></li></ul></li><li class="tocline"><a href="#dealing-with-errors-and-exceptions" class="tocxref"><span class="secno">7. </span>Dealing with errors and exceptions</a><ul class="toc"><li class="tocline"><a href="#the-fileerror-interface" class="tocxref"><span class="secno">7.1 </span>The <code>FileError</code> interface</a><ul class="toc"><li class="tocline"><a href="#attributes-6" class="tocxref"><span class="secno">7.1.1 </span>Attributes</a></li><li class="tocline"><a href="#constants-2" class="tocxref"><span class="secno">7.1.2 </span>Constants</a></li></ul></li><li class="tocline"><a href="#the-fileexception-exception" class="tocxref"><span class="secno">7.2 </span>The FileException exception</a><ul class="toc"><li class="tocline"><a href="#fields" class="tocxref"><span class="secno">7.2.1 </span>Fields</a></li><li class="tocline"><a href="#constants-3" class="tocxref"><span class="secno">7.2.2 </span>Constants</a></li></ul></li><li class="tocline"><a href="#error-code-descriptions" class="tocxref"><span class="secno">7.3 </span>Error Code Descriptions</a></li></ul></li><li class="tocline"><a href="#uniformity-of-interface" class="tocxref"><span class="secno">8. </span>Uniformity of interface</a><ul class="toc"><li class="tocline"><a href="#case-sensitivity" class="tocxref"><span class="secno">8.1 </span>Case-sensitivity</a></li><li class="tocline"><a href="#directories" class="tocxref"><span class="secno">8.2 </span>Directories</a></li><li class="tocline"><a href="#naming-restrictions" class="tocxref"><span class="secno">8.3 </span>Naming restrictions</a></li></ul></li><li class="tocline"><a href="#acknowledgements" class="tocxref"><span class="secno">A. </span>Acknowledgements</a></li><li class="tocline"><a href="#references" class="tocxref"><span class="secno">B. </span>References</a><ul class="toc"><li class="tocline"><a href="#normative-references" class="tocxref"><span class="secno">B.1 </span>Normative references</a></li><li class="tocline"><a href="#informative-references" class="tocxref"><span class="secno">B.2 </span>Informative references</a></li></ul></li></ul></div>
    
    <div id="conformance" class="section"><!--OddPage--><h2><span class="secno">1. </span>Conformance</h2><p>As well as sections marked as non-normative, all authoring guidelines, diagrams, examples, and notes in this specification are non-normative. Everything else in this specification is normative.</p>
<p>The key words <em class="rfc2119" title="must">must</em>, <em class="rfc2119" title="must not">must not</em>, <em class="rfc2119" title="required">required</em>, <em class="rfc2119" title="should">should</em>, <em class="rfc2119" title="should not">should not</em>, <em class="rfc2119" title="recommended">recommended</em>, <em class="rfc2119" title="may">may</em>, and <em class="rfc2119" title="optional">optional</em> in this specification are to be interpreted as described in [<cite><a class="bibref" rel="biblioentry" href="#bib-RFC2119">RFC2119</a></cite>].</p>

      <p>
        This specification defines conformance criteria that apply to a single
        product: a <dfn id="dfn-user-agent">user agent</dfn> that implements the interfaces that it
        contains.
      </p>
    </div>
    
    <div class="informative section" id="introduction">
      <!--OddPage--><h2><span class="secno">2. </span>Introduction</h2><p><em>This section is non-normative.</em></p>
      <p>
        This API is intended to satisfy client-side-storage use cases not
        well served by databases.  These are generally applications that involve
        large binary blobs and/or share data with applications outside of the
        browser.
      </p>
      <p>
        It is intended to be minimal in extent, but sufficiently powerful that
        easy-to-use libraries may be built on top of it.
      </p>
      <div id="use-cases" class="section">
        <h3><span class="secno">2.1 </span>Use Cases</h3>
        <ol>
          <li>Persistent uploader
            <ul>
            <li>When a file or directory is selected for upload, it copies it
            into a local sandbox and uploads a chunk at a time.</li>
            <li>It can restart uploads after browser crashes, network
            interruptions, etc.</li>
            </ul>
          </li>
          <li>Video game or other app with lots of media assets
            <ul>
            <li>It downloads one or several large tarballs, and expands them
            locally into a directory structure.</li>
            <li>The same download should work on any operating system.</li>
            <li>It can manage prefetching just the next-to-be-needed assets in
            the background, so going to the next game level or activating a new
            feature doesn't require waiting for a download.</li>
            <li>It uses those assets directly from its local cache, by direct
            file reads or by handing local URLs to image or video tags, WebGL
            asset loaders, etc.</li>
            <li>The files may be of arbitrary binary format.</li>
            <li>On the server side, a compressed tarball will often be much
            smaller than a collection of separately-compressed files.  Also, 1
            tarball instead of 1000 little files will involve fewer seeks, all
            else being equal.</li>
            </ul>
          </li>

          <li>Audio/Photo editor with offline access or local cache for speed
            <ul>
            <li>The data blobs are potentially quite large, and are
            read-write.</li>
            <li>It may want to do partial writes to files (ovewriting just the
            ID3/EXIF tags, for example).</li>
            <li>The ability to organize project files by creating directories
            would be useful.</li>
            <li>Edited files should be accessable by client-side applications
            [iTunes, Picasa].
            </li></ul>
          </li>

          <li>Offline video viewer
            <ul>
            <li>It downloads large files (&gt;1GB) for later viewing.</li>
            <li>It needs efficient seek + streaming.</li>
            <li>It must be able to hand a URL to the video tag.</li>
            <li>It should enable access to partly-downloaded files e.g.  to let
            you watch the first episode of the DVD even if your download didn't
            complete before you got on the plane.</li>
            <li>It should be able to pull a single episode out of the middle of
            a download and give just that to the video tag.</li>
            </ul>
          </li>

          <li>Offline Web Mail Client
            <ul>
            <li>Downloads attachments and stores them locally.</li>
            <li>Caches user-selected attachments for later upload.</li>
            <li>Needs to be able to refer to cached attachments and image
            thumbnails for display and upload.</li>
            <li>Should be able to trigger the UA's download manager just as if
            talking to a server.</li>
            <li>Should be able to upload an email with attachments as a
            multipart post, rather than sending a file at a time in an XHR.</li>
            </ul>
          </li>
        </ol>
      </div>
      <div id="examples" class="section">
        <h3><span class="secno">2.2 </span>Examples</h3>
        <pre class="example sh_javascript sh_sourceCode"><span class="sh_comment">// In the DOM or worker context:</span>

<span class="sh_keyword">function</span> <span class="sh_function">useAsyncFS</span><span class="sh_symbol">(</span>fs<span class="sh_symbol">)</span> <span class="sh_cbracket">{</span>
  <span class="sh_comment">// see getAsText example in [</span><cite><a class="bibref" rel="biblioentry" href="#bib-FILE-API"><span class="sh_comment">FILE-API</span></a></cite><span class="sh_comment">].</span>
  fs<span class="sh_symbol">.</span>root<span class="sh_symbol">.</span><span class="sh_function">getFile</span><span class="sh_symbol">(</span><span class="sh_string">"already_there.txt"</span><span class="sh_symbol">,</span> <span class="sh_keyword">null</span><span class="sh_symbol">,</span> <span class="sh_keyword">function</span> <span class="sh_symbol">(</span>f<span class="sh_symbol">)</span> <span class="sh_cbracket">{</span>
    <span class="sh_function">getAsText</span><span class="sh_symbol">(</span>f<span class="sh_symbol">.</span><span class="sh_function">file</span><span class="sh_symbol">());</span>
  <span class="sh_cbracket">}</span><span class="sh_symbol">);</span>

  <span class="sh_comment">// But now we can also write to the file; see [</span><cite><a class="bibref" rel="biblioentry" href="#bib-FILE-WRITER"><span class="sh_comment">FILE-WRITER</span></a></cite><span class="sh_comment">].</span>
  fs<span class="sh_symbol">.</span>root<span class="sh_symbol">.</span><span class="sh_function">getFile</span><span class="sh_symbol">(</span><span class="sh_string">"logFile"</span><span class="sh_symbol">,</span> <span class="sh_cbracket">{</span>create<span class="sh_symbol">:</span> <span class="sh_keyword">true</span><span class="sh_cbracket">}</span><span class="sh_symbol">,</span> <span class="sh_keyword">function</span> <span class="sh_symbol">(</span>f<span class="sh_symbol">)</span> <span class="sh_cbracket">{</span>
    f<span class="sh_symbol">.</span><span class="sh_function">createWriter</span><span class="sh_symbol">(</span>writeDataToLogFile<span class="sh_symbol">);</span>
  <span class="sh_cbracket">}</span><span class="sh_symbol">);</span>
<span class="sh_cbracket">}</span>
<span class="sh_function">requestFileSystem</span><span class="sh_symbol">(</span>TEMPORARY<span class="sh_symbol">,</span> <span class="sh_number">1024</span> <span class="sh_symbol">*</span> <span class="sh_number">1024</span><span class="sh_symbol">,</span> <span class="sh_keyword">function</span><span class="sh_symbol">(</span>fs<span class="sh_symbol">)</span> <span class="sh_cbracket">{</span>
  <span class="sh_function">useAsyncFS</span><span class="sh_symbol">(</span>fs<span class="sh_symbol">);</span>
<span class="sh_cbracket">}</span><span class="sh_symbol">);</span>

<span class="sh_comment">// In a worker:</span>

<span class="sh_keyword">var</span> tempFS <span class="sh_symbol">=</span> <span class="sh_function">requestFileSystem</span><span class="sh_symbol">(</span>TEMPORARY<span class="sh_symbol">,</span> <span class="sh_number">1024</span> <span class="sh_symbol">*</span> <span class="sh_number">1024</span><span class="sh_symbol">);</span>
<span class="sh_keyword">var</span> logFile <span class="sh_symbol">=</span> tempFS<span class="sh_symbol">.</span>root<span class="sh_symbol">.</span><span class="sh_function">getFile</span><span class="sh_symbol">(</span><span class="sh_string">"logFile"</span><span class="sh_symbol">,</span> <span class="sh_cbracket">{</span>create<span class="sh_symbol">:</span> <span class="sh_keyword">true</span><span class="sh_cbracket">}</span><span class="sh_symbol">);</span>
<span class="sh_keyword">var</span> writer <span class="sh_symbol">=</span> logFile<span class="sh_symbol">.</span><span class="sh_function">createWriter</span><span class="sh_symbol">();</span>
writer<span class="sh_symbol">.</span><span class="sh_function">seek</span><span class="sh_symbol">(</span>writer<span class="sh_symbol">.</span>length<span class="sh_symbol">);</span>
<span class="sh_function">writeDataToLogFile</span><span class="sh_symbol">(</span>writer<span class="sh_symbol">);</span></pre>
      </div>
    </div>
    
    <div id="data-persistence-and-accessing-the-api" class="section">
      <!--OddPage--><h2><span class="secno">3. </span>Data Persistence and accessing the API</h2>
      <div class="informative section" id="temporary-vs.-persistent-storage">
        <h3><span class="secno">3.1 </span>Temporary vs. Persistent Storage</h3><p><em>This section is non-normative.</em></p>
        <p>
          An application can request <a href="#dfn-temporary" class="internalDFN">temporary</a> or <a href="#dfn-persistent" class="internalDFN">persistent</a>
          storage space.  Temporary storage may be easier to get, at the UA's
          discretion [looser quota restrictions, available without prompting the
          user], but the data stored there may be deleted at the UA's
          convenience, e.g. to deal with a shortage of disk space.
        </p>
        <p>
          Conversely, once <a href="#dfn-persistent" class="internalDFN">persistent</a> storage has been granted, data
          stored there by the application should not be deleted by the UA
          without user intervention.  The application may of course delete it at
          will.  The UA should require permission from the user before granting
          <a href="#dfn-persistent" class="internalDFN">persistent</a> storage space to the application.
        </p>
        <p>
          This API specifies the standard origin isolation in a filesystem
          context, along with persistence of data across invocations.
          Applications will likely use <a href="#dfn-temporary" class="internalDFN">temporary</a> storage for caching, and
          if it's still around from a previous session, it is often useful.
          Persistent data, on the other hand, is useless if you can't access it
          again the next time you're invoked.  However, even <a href="#dfn-persistent" class="internalDFN">persistent</a>
          data may be deleted manually by the user [either through the UA or via
          direct filesystem operations].
        </p>
      </div>
      <div id="restrictions" class="section">
        <h3><span class="secno">3.2 </span>Restrictions</h3>
        <a href="#idl-def-FileSystem" class="idlType"><code>FileSystem</code></a> and <a href="#idl-def-FileSystemSync" class="idlType"><code>FileSystemSync</code></a> objects returned by
        <code>requestFileSystem</code> <em class="rfc2119" title="must">must</em> have the following properties:
        <ul>
          <li>The filesystems accessible by any origin <em class="rfc2119" title="must">must</em> be disjoint from
          those accessible by any other origin.</li>
          <li>Data stored in a <dfn id="dfn-persistent">persistent</dfn> filesystem <em class="rfc2119" title="should not">should not</em> be
          deleted by the UA, other than in response to a removal API call,
          without explicit authorization from the user.</li>
          <li>Data stored in a <dfn id="dfn-temporary">temporary</dfn> filesystem <em class="rfc2119" title="may">may</em> be deleted by
          the UA at its discretion, without application or user
          intervention.</li>
          <li>If
            <ol>
              <li> an application in a given origin requests a <a href="#dfn-persistent" class="internalDFN">persistent</a>
              filesystem on multiple occasions;</li>
              <li> each request is granted;</li>
              <li> and data from an earlier request still exists in the first
              filesystem at the time of a subsequent request.</li>
            </ol>
            then the <a href="#idl-def-FileSystem" class="idlType"><code>FileSystem</code></a> or <a href="#idl-def-FileSystemSync" class="idlType"><code>FileSystemSync</code></a> returned from
            the subsequent request <em class="rfc2119" title="must">must</em> refer to the same underlying filesystem
            and root directory as the previous request.</li>
          <li>If
            <ol>
              <li> an application in a given origin requests a <a href="#dfn-temporary" class="internalDFN">temporary</a>
              filesystem on multiple occasions;</li>
              <li> each request is granted;</li>
              <li> and data from an earlier request still exists in the first
              filesystem at the time of a subsequent request.</li>
            </ol>
            then the <a href="#idl-def-FileSystem" class="idlType"><code>FileSystem</code></a> or <a href="#idl-def-FileSystemSync" class="idlType"><code>FileSystemSync</code></a> returned from
            the subsequent request <em class="rfc2119" title="should">should</em> refer to the same underlying
            filesystem and root directory as the previous request.</li>
        </ul>
        <div class="issue">
          <p>
          Do we need to mandate that the <a href="#dfn-temporary" class="internalDFN">temporary</a> and
          <a href="#dfn-persistent" class="internalDFN">persistent</a> filesystems be disjoint?
          </p>
        </div>
      </div>
      <div class="informative section" id="security-considerations">
        <h3><span class="secno">3.3 </span>Security Considerations</h3><p><em>This section is non-normative.</em></p>
        <p>
          Because this API may allow untrusted code to read and write parts of a
          user's hard drive, there are a number of security and privacy issues
          that must be dealt with.  Risks to the user include:
          </p><ul>
            <li>Denial of service by filling a local disk or using up IO
            bandwidth.  This can be mitigated in part through quota
            limitations.</li>
            <li>Theft or erasure of private data.  This is mitigated by limiting
            the scope of access to the local filesystem to a chroot-like,
            origin-specific sandbox.</li>
            <li>Storing malicious executables or illegal data on a user's
            system.  This is similar to the risk of any download, and similar
            security precautions apply, but is potentially worse in that:
              <ul>
                <li>It may involve multiple files.</li>
                <li>The files may be in a part of the filesystem that's harder
                for the user to find than the standard downloads directory.</li>
                <li>The malicious writes may happen long enough after granting
                of filesystem access that the user doesn't connect the two
                events.</li>
              </ul>
            This may be mitigated by restricting file creation/rename to
            non-executable extensions, and by making sure the execute bit is
            not set on any file created or modified via the API.
            </li>
          </ul>
        <p></p>
        <p>
          As with any other client-side storage, filesystem access allows for
          cookie-resurrection attacks.  UAs will likely wish to present the
          option of clearing it when the user clears any other origin-specific
          storage, blocking access to it when cookies are blocked, etc.  This is
          especially important if <a href="#dfn-temporary" class="internalDFN">temporary</a> storage space is permitted by
          default without explicit user permission.
        </p>
      </div>
      <div id="obtaining-access-to-file-system-entry-points" class="section">
        <h3><span class="secno">3.4 </span>Obtaining access to file system entry points</h3>
        <p>
          There are several ways in which a file system entry point can be
          obtained. Not all <a>user agents</a> may in fact implement all of
          them.  However, in order to avoid blocking UI actions while waiting on
          filesystem IO, we define only an asynchronous interface for Window,
          and restrict the synchronous API to the Worker context defined in
          [<cite><a class="bibref" rel="biblioentry" href="#bib-WEBWORKERS">WEBWORKERS</a></cite>].
        </p>
        <div id="using-localfilesystem" class="section">
          <h4><span class="secno">3.4.1 </span>Using <code>LocalFileSystem</code></h4>
          <pre class="idl"><span class="idlImplements"><a>Window</a> implements <a href="#idl-def-LocalFileSystem" class="idlType"><code>LocalFileSystem</code></a>;</span></pre><div class="idlImplementsDesc"><p>All instances of the <code><a>Window</a></code> type are defined to also implement the <a href="#idl-def-LocalFileSystem" class="idlType"><code>LocalFileSystem</code></a> interface.</p></div>
          <pre class="idl"><span class="idlImplements"><a>WorkerGlobalScope</a> implements <a href="#idl-def-LocalFileSystem" class="idlType"><code>LocalFileSystem</code></a>;</span></pre><div class="idlImplementsDesc"><p>All instances of the <code><a>WorkerGlobalScope</a></code> type are defined to also implement the <a href="#idl-def-LocalFileSystem" class="idlType"><code>LocalFileSystem</code></a> interface.</p></div> <pre class="idl"><span class="idlInterface" id="idl-def-LocalFileSystem">[<span class="extAttr">Supplemental, NoInterfaceObject</span>]
interface <span class="idlInterfaceID">LocalFileSystem</span> {
<span class="idlConst">    const <span class="idlConstType"><a>unsigned short</a></span> <span class="idlConstName"><a href="#widl-LocalFileSystem-TEMPORARY">TEMPORARY</a></span> = <span class="idlConstValue">0</span>;</span>
<span class="idlConst">    const <span class="idlConstType"><a>unsigned short</a></span> <span class="idlConstName"><a href="#widl-LocalFileSystem-PERSISTENT">PERSISTENT</a></span> = <span class="idlConstValue">1</span>;</span>
<span class="idlMethod">    <span class="idlMethType"><a>void</a></span> <span class="idlMethName"><a href="#widl-LocalFileSystem-requestFileSystem">requestFileSystem</a></span> (<span class="idlParam"><span class="idlParamType"><a>unsigned short</a></span> <span class="idlParamName">type</span></span>, <span class="idlParam"><span class="idlParamType"><a>unsigned long long</a></span> <span class="idlParamName">size</span></span>, <span class="idlParam"><span class="idlParamType"><a href="#idl-def-FileSystemCallback" class="idlType"><code>FileSystemCallback</code></a></span> <span class="idlParamName">successCallback</span></span>, <span class="idlParam">optional <span class="idlParamType"><a href="#idl-def-ErrorCallback" class="idlType"><code>ErrorCallback</code></a></span> <span class="idlParamName">errorCallback</span></span>);</span>
<span class="idlMethod">    <span class="idlMethType"><a>void</a></span> <span class="idlMethName"><a href="#widl-LocalFileSystem-resolveLocalFileSystemURL">resolveLocalFileSystemURL</a></span> (<span class="idlParam"><span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">url</span></span>, <span class="idlParam"><span class="idlParamType"><a href="#idl-def-EntryCallback" class="idlType"><code>EntryCallback</code></a></span> <span class="idlParamName">successCallback</span></span>, <span class="idlParam">optional <span class="idlParamType"><a href="#idl-def-ErrorCallback" class="idlType"><code>ErrorCallback</code></a></span> <span class="idlParamName">errorCallback</span></span>);</span>
};</span>
</pre><div id="methods" class="section"><h5><span class="secno">3.4.1.1 </span>Methods</h5><dl class="methods"><dt id="widl-LocalFileSystem-requestFileSystem"><code>requestFileSystem</code></dt><dd>
              <p>
                Requests a filesystem in which to store application data.
              </p>
              <p>
                If successful, this function <em class="rfc2119" title="must">must</em> give access to an
                origin-private filesystem, as defined above.
              </p>
              
            <table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">type</td><td class="prmType"><code><a>unsigned short</a></code></td><td class="prmNullFalse">?</td><td class="prmOptFalse">?</td><td class="prmDesc">
                  Whether the filesystem requested should be <a href="#dfn-persistent" class="internalDFN">persistent</a>,
                  as defined above.  Use one of <code>TEMPORARY</code> or
                  <code>PERSISTENT</code>.
                </td></tr><tr><td class="prmName">size</td><td class="prmType"><code><a>unsigned long long</a></code></td><td class="prmNullFalse">?</td><td class="prmOptFalse">?</td><td class="prmDesc">
                  This is an indicator of how much storage space, in bytes, the
                  application expects to need.
                </td></tr><tr><td class="prmName">successCallback</td><td class="prmType"><code><a href="#idl-def-FileSystemCallback" class="idlType"><code>FileSystemCallback</code></a></code></td><td class="prmNullFalse">?</td><td class="prmOptFalse">?</td><td class="prmDesc">
                The callback that is called when the <a href="#dfn-user-agent" class="internalDFN">user agent</a> provides
                a filesystem.
                </td></tr><tr><td class="prmName">errorCallback</td><td class="prmType"><code><a href="#idl-def-ErrorCallback" class="idlType"><code>ErrorCallback</code></a></code></td><td class="prmNullFalse">?</td><td class="prmOptTrue">?</td><td class="prmDesc">
                  A callback that is called when errors happen, or when the
                  request to obtain the filesystem is denied.
                </td></tr></table><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a>void</a></code></div></dd><dt id="widl-LocalFileSystem-resolveLocalFileSystemURL"><code>resolveLocalFileSystemURL</code></dt><dd>
              <p>
                Allows the user to look up the Entry for a file or directory
                referred to by a local URL.
              </p>
              
            <table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">url</td><td class="prmType"><code><a>DOMString</a></code></td><td class="prmNullFalse">?</td><td class="prmOptFalse">?</td><td class="prmDesc">
                  A URL referring to a local file in a filesystem accessable via
                  this API.
                </td></tr><tr><td class="prmName">successCallback</td><td class="prmType"><code><a href="#idl-def-EntryCallback" class="idlType"><code>EntryCallback</code></a></code></td><td class="prmNullFalse">?</td><td class="prmOptFalse">?</td><td class="prmDesc">
                  A callback that is called to report the Entry to which the
                  supplied URL refers.
                </td></tr><tr><td class="prmName">errorCallback</td><td class="prmType"><code><a href="#idl-def-ErrorCallback" class="idlType"><code>ErrorCallback</code></a></code></td><td class="prmNullFalse">?</td><td class="prmOptTrue">?</td><td class="prmDesc">
                  A callback that is called when errors happen, or when the
                  request to obtain the Entry is denied.
                </td></tr></table><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a>void</a></code></div></dd></dl></div><div id="constants" class="section"><h5><span class="secno">3.4.1.2 </span>Constants</h5><dl class="constants"><dt id="widl-LocalFileSystem-PERSISTENT"><code>PERSISTENT</code> of type <span class="idlConstType"><a>unsigned short</a></span></dt><dd>
              Used for storage that should not be removed by the <a href="#dfn-user-agent" class="internalDFN">user
              agent</a> without application or user permission.
            </dd><dt id="widl-LocalFileSystem-TEMPORARY"><code>TEMPORARY</code> of type <span class="idlConstType"><a>unsigned short</a></span></dt><dd>
              Used for storage with no guarantee of persistence.
            </dd></dl></div>
        </div>
        <div id="using-localfilesystemsync" class="section">
          <h4><span class="secno">3.4.2 </span>Using <code>LocalFileSystemSync</code></h4>
          <pre class="idl"><span class="idlImplements"><a>WorkerGlobalScope</a> implements <a href="#idl-def-LocalFileSystemSync" class="idlType"><code>LocalFileSystemSync</code></a>;</span></pre><div class="idlImplementsDesc"><p>All instances of the <code><a>WorkerGlobalScope</a></code> type are defined to also implement the <a href="#idl-def-LocalFileSystemSync" class="idlType"><code>LocalFileSystemSync</code></a> interface.</p></div>
          <pre class="idl"><span class="idlInterface" id="idl-def-LocalFileSystemSync">[<span class="extAttr">Supplemental, NoInterfaceObject</span>]
interface <span class="idlInterfaceID">LocalFileSystemSync</span> {
<span class="idlConst">    const <span class="idlConstType"><a>unsigned short</a></span> <span class="idlConstName"><a href="#widl-LocalFileSystemSync-TEMPORARY">TEMPORARY</a></span> = <span class="idlConstValue">0</span>;</span>
<span class="idlConst">    const <span class="idlConstType"><a>unsigned short</a></span> <span class="idlConstName"><a href="#widl-LocalFileSystemSync-PERSISTENT">PERSISTENT</a></span> = <span class="idlConstValue">1</span>;</span>
<span class="idlMethod">    <span class="idlMethType"><a href="#idl-def-FileSystemSync" class="idlType"><code>FileSystemSync</code></a></span> <span class="idlMethName"><a href="#widl-LocalFileSystemSync-requestFileSystemSync">requestFileSystemSync</a></span> (<span class="idlParam"><span class="idlParamType"><a>unsigned short</a></span> <span class="idlParamName">type</span></span>, <span class="idlParam"><span class="idlParamType"><a>unsigned long long</a></span> <span class="idlParamName">size</span></span>) raises (<span class="idlRaises"><a href="#idl-def-FileException" class="idlType"><code>FileException</code></a></span>);</span>
<span class="idlMethod">    <span class="idlMethType"><a href="#idl-def-EntrySync" class="idlType"><code>EntrySync</code></a></span>      <span class="idlMethName"><a href="#widl-LocalFileSystemSync-resolveLocalFileSystemSyncURL">resolveLocalFileSystemSyncURL</a></span> (<span class="idlParam"><span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">url</span></span>) raises (<span class="idlRaises"><a href="#idl-def-FileException" class="idlType"><code>FileException</code></a></span>);</span>
};</span>
</pre><div id="methods-1" class="section"><h5><span class="secno">3.4.2.1 </span>Methods</h5><dl class="methods"><dt id="widl-LocalFileSystemSync-requestFileSystemSync"><code>requestFileSystemSync</code></dt><dd>
              <p>
                Requests a filesystem in which to store application data.
              </p>
              <p>
                If successful, this function <em class="rfc2119" title="must">must</em> give access to an
                origin-private filesystem, as defined above.
              </p>
              
              
            <table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">type</td><td class="prmType"><code><a>unsigned short</a></code></td><td class="prmNullFalse">?</td><td class="prmOptFalse">?</td><td class="prmDesc">
                  Whether the filesystem requested should be <a href="#dfn-persistent" class="internalDFN">persistent</a>,
                  as defined above.  Use one of <code>TEMPORARY</code> or
                  <code>PERSISTENT</code>.
                </td></tr><tr><td class="prmName">size</td><td class="prmType"><code><a>unsigned long long</a></code></td><td class="prmNullFalse">?</td><td class="prmOptFalse">?</td><td class="prmDesc">
                  This is an indicator of how much storage space, in bytes, the
                  application expects to need.
                </td></tr></table><table class="exceptions"><tr><th>Exception</th><th>Description</th></tr><tr><td class="excName"><a href="#idl-def-FileException" class="idlType"><code>FileException</code></a></td><td class="excDesc"><table class="exceptionCodes"><tr><td class="excCodeName"><code>SECURITY_ERR</code></td><td class="excCodeDesc">The application does not have permission to access the
                filesystem interface.</td></tr></table></td></tr></table><div><em>Return type: </em><code><a href="#idl-def-FileSystemSync" class="idlType"><code>FileSystemSync</code></a></code></div></dd><dt id="widl-LocalFileSystemSync-resolveLocalFileSystemSyncURL"><code>resolveLocalFileSystemSyncURL</code></dt><dd>
              <p>
                Allows the user to look up the Entry for a file or directory
                referred to by a local URL.
              </p>
              
              
            <table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">url</td><td class="prmType"><code><a>DOMString</a></code></td><td class="prmNullFalse">?</td><td class="prmOptFalse">?</td><td class="prmDesc">
                  A URL referring to a local file in a filesystem accessable via
                  this API.
                </td></tr></table><table class="exceptions"><tr><th>Exception</th><th>Description</th></tr><tr><td class="excName"><a href="#idl-def-FileException" class="idlType"><code>FileException</code></a></td><td class="excDesc"><table class="exceptionCodes"><tr><td class="excCodeName"><code>ENCODING_ERR</code></td><td class="excCodeDesc">The URL was invalid.</td></tr><tr><td class="excCodeName"><code>NOT_FOUND_ERR</code></td><td class="excCodeDesc">The URL was structurally correct, but refers to a resource
                that does not exist.</td></tr><tr><td class="excCodeName"><code>SECURITY_ERR</code></td><td class="excCodeDesc">The application does not have permission to access the
                filesystem interface or the element referred to by the URL.</td></tr></table></td></tr></table><div><em>Return type: </em><code><a href="#idl-def-EntrySync" class="idlType"><code>EntrySync</code></a></code></div></dd></dl></div><div id="constants-1" class="section"><h5><span class="secno">3.4.2.2 </span>Constants</h5><dl class="constants"><dt id="widl-LocalFileSystemSync-PERSISTENT"><code>PERSISTENT</code> of type <span class="idlConstType"><a>unsigned short</a></span></dt><dd>
              Used for storage that should not be removed by the <a href="#dfn-user-agent" class="internalDFN">user
              agent</a> without application or user permission.
            </dd><dt id="widl-LocalFileSystemSync-TEMPORARY"><code>TEMPORARY</code> of type <span class="idlConstType"><a>unsigned short</a></span></dt><dd>
              Used for storage with no guarantee of persistence.
            </dd></dl></div>
        </div>
      </div>
    </div>
    
    <div id="shared-data-types" class="section">
      <!--OddPage--><h2><span class="secno">4. </span>Shared data types</h2>
      <div id="the-metadata-interface" class="section">
        <h3><span class="secno">4.1 </span>The <code>Metadata</code> interface</h3>
        <p>
          This interface supplies information about the state of a file or
          directory.
        </p>
        <pre class="idl"><span class="idlInterface" id="idl-def-Metadata">[<span class="extAttr">NoInterfaceObject</span>]
interface <span class="idlInterfaceID">Metadata</span> {
<span class="idlAttribute">    readonly attribute <span class="idlAttrType"><a>Date</a></span> <span class="idlAttrName"><a href="#widl-Metadata-modificationTime">modificationTime</a></span>;</span>
};</span>
</pre><div id="attributes" class="section"><h4><span class="secno">4.1.1 </span>Attributes</h4><dl class="attributes"><dt id="widl-Metadata-modificationTime"><code>modificationTime</code> of type <span class="idlAttrType"><a>Date</a></span>, readonly</dt><dd>
            This is the time at which the file or directory was last modified.
          <div><em>No exceptions.</em></div></dd></dl></div>
      </div>
      <div id="the-flags-interface" class="section">
        <h3><span class="secno">4.2 </span>The <code>Flags</code> interface</h3>
        <p>
          This interface is used to supply arguments to methods that look up or
          create files or directories.
        </p>
        <pre class="idl"><span class="idlInterface" id="idl-def-Flags">[<span class="extAttr">NoInterfaceObject</span>]
interface <span class="idlInterfaceID">Flags</span> {
<span class="idlAttribute">    attribute <span class="idlAttrType"><a>boolean</a></span> <span class="idlAttrName"><a href="#widl-Flags-create">create</a></span>;</span>
<span class="idlAttribute">    attribute <span class="idlAttrType"><a>boolean</a></span> <span class="idlAttrName"><a href="#widl-Flags-exclusive">exclusive</a></span>;</span>
};</span>
</pre><div id="attributes-1" class="section"><h4><span class="secno">4.2.1 </span>Attributes</h4><dl class="attributes"><dt id="widl-Flags-create"><code>create</code> of type <span class="idlAttrType"><a>boolean</a></span></dt><dd>
            Used to indicate that the user wants to create a file or directory
            if it was not previously there.
          <div><em>No exceptions.</em></div></dd><dt id="widl-Flags-exclusive"><code>exclusive</code> of type <span class="idlAttrType"><a>boolean</a></span></dt><dd>
            By itself, <code>exclusive</code> <em class="rfc2119" title="must">must</em> have no effect.  Used with
            <code>create</code>, it causes getFile and getDirectory to
            fail if the target path already exists.
          <div><em>No exceptions.</em></div></dd></dl></div>
        <div class="informative section" id="examples-1">
          <h4><span class="secno">4.2.2 </span>Examples</h4><p><em>This section is non-normative.</em></p>
          <pre class="example sh_javascript sh_sourceCode"><span class="sh_comment">// Get the data directory, creating it if it doesn't exist.</span>
dataDir <span class="sh_symbol">=</span> fsSync<span class="sh_symbol">.</span>root<span class="sh_symbol">.</span><span class="sh_function">getDirectory</span><span class="sh_symbol">(</span><span class="sh_string">"data"</span><span class="sh_symbol">,</span> <span class="sh_cbracket">{</span>create<span class="sh_symbol">:</span> <span class="sh_keyword">true</span><span class="sh_cbracket">}</span><span class="sh_symbol">);</span>

<span class="sh_comment">// Create the lock file, if and only if it doesn't exist.</span>
<span class="sh_keyword">try</span> <span class="sh_cbracket">{</span>
  lockFile <span class="sh_symbol">=</span> dataDir<span class="sh_symbol">.</span><span class="sh_function">getFile</span><span class="sh_symbol">(</span><span class="sh_string">"lockfile.txt"</span><span class="sh_symbol">,</span>
                             <span class="sh_cbracket">{</span>create<span class="sh_symbol">:</span> <span class="sh_keyword">true</span><span class="sh_symbol">,</span> exclusive<span class="sh_symbol">:</span> <span class="sh_keyword">true</span><span class="sh_cbracket">}</span><span class="sh_symbol">);</span>
<span class="sh_cbracket">}</span> <span class="sh_keyword">catch</span> <span class="sh_symbol">(</span>ex<span class="sh_symbol">)</span> <span class="sh_cbracket">{</span>
  <span class="sh_comment">// It already exists, or something else went wrong.</span>
  <span class="sh_symbol">...</span>
<span class="sh_cbracket">}</span></pre>
        </div>
      </div>
    </div>

    <div id="the-asynchronous-filesystem-interface" class="section">
      <!--OddPage--><h2><span class="secno">5. </span>The asynchronous filesystem interface</h2>
      <div id="the-filesystem-interface" class="section">
        <h3><span class="secno">5.1 </span>The <code>FileSystem</code> interface</h3>
        <p>
          This interface represents a file system.
        </p>
        <pre class="idl"><span class="idlInterface" id="idl-def-FileSystem">[<span class="extAttr">NoInterfaceObject</span>]
interface <span class="idlInterfaceID">FileSystem</span> {
<span class="idlAttribute">    readonly attribute <span class="idlAttrType"><a>DOMString</a></span>      <span class="idlAttrName"><a href="#widl-FileSystem-name">name</a></span>;</span>
<span class="idlAttribute">    readonly attribute <span class="idlAttrType"><a href="#idl-def-DirectoryEntry" class="idlType"><code>DirectoryEntry</code></a></span> <span class="idlAttrName"><a href="#widl-FileSystem-root">root</a></span>;</span>
};</span>
</pre><div id="attributes-2" class="section"><h4><span class="secno">5.1.1 </span>Attributes</h4><dl class="attributes"><dt id="widl-FileSystem-name"><code>name</code> of type <span class="idlAttrType"><a>DOMString</a></span>, readonly</dt><dd>
            This is the name of the file system.  The specifics of naming
            filesystems is unspecified, but a name <em class="rfc2119" title="must">must</em> be unique across the
            list of exposed file systems.
          <div><em>No exceptions.</em></div></dd><dt id="widl-FileSystem-root"><code>root</code> of type <span class="idlAttrType"><a href="#idl-def-DirectoryEntry" class="idlType"><code>DirectoryEntry</code></a></span>, readonly</dt><dd>
            The root directory of the file system.
          <div><em>No exceptions.</em></div></dd></dl></div>
      </div>

      <div id="the-entry-interface" class="section">
        <h3><span class="secno">5.2 </span>The <code>Entry</code> interface</h3>
        <p>
          An abstract interface representing entries in a file system, each of
          which may be a <a>File</a> or <a href="#idl-def-DirectoryEntry" class="idlType"><code>DirectoryEntry</code></a>.
        </p>
        <pre class="idl"><span class="idlInterface" id="idl-def-Entry">[<span class="extAttr">NoInterfaceObject</span>]
interface <span class="idlInterfaceID">Entry</span> {
<span class="idlAttribute">    readonly attribute <span class="idlAttrType"><a>boolean</a></span>    <span class="idlAttrName"><a href="#widl-Entry-isFile">isFile</a></span>;</span>
<span class="idlAttribute">    readonly attribute <span class="idlAttrType"><a>boolean</a></span>    <span class="idlAttrName"><a href="#widl-Entry-isDirectory">isDirectory</a></span>;</span>
<span class="idlMethod">    <span class="idlMethType"><a>void</a></span>      <span class="idlMethName"><a href="#widl-Entry-getMetadata">getMetadata</a></span> (<span class="idlParam"><span class="idlParamType"><a href="#idl-def-MetadataCallback" class="idlType"><code>MetadataCallback</code></a></span> <span class="idlParamName">successCallback</span></span>, <span class="idlParam">optional <span class="idlParamType"><a href="#idl-def-ErrorCallback" class="idlType"><code>ErrorCallback</code></a></span> <span class="idlParamName">errorCallback</span></span>);</span>
<span class="idlAttribute">    readonly attribute <span class="idlAttrType"><a>DOMString</a></span>  <span class="idlAttrName"><a href="#widl-Entry-name">name</a></span>;</span>
<span class="idlAttribute">    readonly attribute <span class="idlAttrType"><a>DOMString</a></span>  <span class="idlAttrName"><a href="#widl-Entry-fullPath">fullPath</a></span>;</span>
<span class="idlAttribute">    readonly attribute <span class="idlAttrType"><a href="#idl-def-FileSystem" class="idlType"><code>FileSystem</code></a></span> <span class="idlAttrName"><a href="#widl-Entry-filesystem">filesystem</a></span>;</span>
<span class="idlMethod">    <span class="idlMethType"><a>void</a></span>      <span class="idlMethName"><a href="#widl-Entry-moveTo">moveTo</a></span> (<span class="idlParam"><span class="idlParamType"><a href="#idl-def-DirectoryEntry" class="idlType"><code>DirectoryEntry</code></a></span> <span class="idlParamName">parent</span></span>, <span class="idlParam">optional <span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">newName</span></span>, <span class="idlParam">optional <span class="idlParamType"><a href="#idl-def-EntryCallback" class="idlType"><code>EntryCallback</code></a></span> <span class="idlParamName">successCallback</span></span>, <span class="idlParam">optional <span class="idlParamType"><a href="#idl-def-ErrorCallback" class="idlType"><code>ErrorCallback</code></a></span> <span class="idlParamName">errorCallback</span></span>);</span>
<span class="idlMethod">    <span class="idlMethType"><a>void</a></span>      <span class="idlMethName"><a href="#widl-Entry-copyTo">copyTo</a></span> (<span class="idlParam"><span class="idlParamType"><a href="#idl-def-DirectoryEntry" class="idlType"><code>DirectoryEntry</code></a></span> <span class="idlParamName">parent</span></span>, <span class="idlParam">optional <span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">newName</span></span>, <span class="idlParam">optional <span class="idlParamType"><a href="#idl-def-EntryCallback" class="idlType"><code>EntryCallback</code></a></span> <span class="idlParamName">successCallback</span></span>, <span class="idlParam">optional <span class="idlParamType"><a href="#idl-def-ErrorCallback" class="idlType"><code>ErrorCallback</code></a></span> <span class="idlParamName">errorCallback</span></span>);</span>
<span class="idlMethod">    <span class="idlMethType"><a>DOMString</a></span> <span class="idlMethName"><a href="#widl-Entry-toURL">toURL</a></span> (<span class="idlParam">optional <span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">mimeType</span></span>);</span>
<span class="idlMethod">    <span class="idlMethType"><a>void</a></span>      <span class="idlMethName"><a href="#widl-Entry-remove">remove</a></span> (<span class="idlParam"><span class="idlParamType"><a href="#idl-def-VoidCallback" class="idlType"><code>VoidCallback</code></a></span> <span class="idlParamName">successCallback</span></span>, <span class="idlParam">optional <span class="idlParamType"><a href="#idl-def-ErrorCallback" class="idlType"><code>ErrorCallback</code></a></span> <span class="idlParamName">errorCallback</span></span>);</span>
<span class="idlMethod">    <span class="idlMethType"><a>void</a></span>      <span class="idlMethName"><a href="#widl-Entry-getParent">getParent</a></span> (<span class="idlParam"><span class="idlParamType"><a href="#idl-def-EntryCallback" class="idlType"><code>EntryCallback</code></a></span> <span class="idlParamName">successCallback</span></span>, <span class="idlParam">optional <span class="idlParamType"><a href="#idl-def-ErrorCallback" class="idlType"><code>ErrorCallback</code></a></span> <span class="idlParamName">errorCallback</span></span>);</span>
};</span>
</pre><div id="attributes-3" class="section"><h4><span class="secno">5.2.1 </span>Attributes</h4><dl class="attributes"><dt id="widl-Entry-filesystem"><code>filesystem</code> of type <span class="idlAttrType"><a href="#idl-def-FileSystem" class="idlType"><code>FileSystem</code></a></span>, readonly</dt><dd>
            The file system on which the entry resides.
          <div><em>No exceptions.</em></div></dd><dt id="widl-Entry-fullPath"><code>fullPath</code> of type <span class="idlAttrType"><a>DOMString</a></span>, readonly</dt><dd>
            The full <a href="#dfn-absolute-path" class="internalDFN">absolute path</a> from the root to the entry.
          <div><em>No exceptions.</em></div></dd><dt id="widl-Entry-isDirectory"><code>isDirectory</code> of type <span class="idlAttrType"><a>boolean</a></span>, readonly</dt><dd>
            Entry is a directory.
          <div><em>No exceptions.</em></div></dd><dt id="widl-Entry-isFile"><code>isFile</code> of type <span class="idlAttrType"><a>boolean</a></span>, readonly</dt><dd>
            Entry is a file.
          <div><em>No exceptions.</em></div></dd><dt id="widl-Entry-name"><code>name</code> of type <span class="idlAttrType"><a>DOMString</a></span>, readonly</dt><dd>
            The name of the entry, excluding the path leading to it.
          <div><em>No exceptions.</em></div></dd></dl></div><div id="methods-2" class="section"><h4><span class="secno">5.2.2 </span>Methods</h4><dl class="methods"><dt id="widl-Entry-copyTo"><code>copyTo</code></dt><dd>
            <p>
              Copy an entry to a different location on the file system. It is an
              error to try to copy an entry inside itself at any depth if it is
              a directory, or to copy it into its parent if a name different
              from its current one isn't provided.  Directory copies are always
              recursive--that is, they copy all contents of the directory.
            </p>
            
          <table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">parent</td><td class="prmType"><code><a href="#idl-def-DirectoryEntry" class="idlType"><code>DirectoryEntry</code></a></code></td><td class="prmNullFalse">?</td><td class="prmOptFalse">?</td><td class="prmDesc">
                The directory to which to move the entry.
              </td></tr><tr><td class="prmName">newName</td><td class="prmType"><code><a>DOMString</a></code></td><td class="prmNullFalse">?</td><td class="prmOptTrue">?</td><td class="prmDesc">
                The new name of the entry.  Defaults to the Entry's current name
                if unspecified.
              </td></tr><tr><td class="prmName">successCallback</td><td class="prmType"><code><a href="#idl-def-EntryCallback" class="idlType"><code>EntryCallback</code></a></code></td><td class="prmNullFalse">?</td><td class="prmOptTrue">?</td><td class="prmDesc">
                A callback that is called with the Entry for the new object.
              </td></tr><tr><td class="prmName">errorCallback</td><td class="prmType"><code><a href="#idl-def-ErrorCallback" class="idlType"><code>ErrorCallback</code></a></code></td><td class="prmNullFalse">?</td><td class="prmOptTrue">?</td><td class="prmDesc">
                A callback that is called when errors happen.
              </td></tr></table><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a>void</a></code></div></dd><dt id="widl-Entry-getMetadata"><code>getMetadata</code></dt><dd>
            <p>
              Look up metadata about this entry.
            </p>
            
          <table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">successCallback</td><td class="prmType"><code><a href="#idl-def-MetadataCallback" class="idlType"><code>MetadataCallback</code></a></code></td><td class="prmNullFalse">?</td><td class="prmOptFalse">?</td><td class="prmDesc">
                A callback that is called with the time of the last
                modification.
              </td></tr><tr><td class="prmName">errorCallback</td><td class="prmType"><code><a href="#idl-def-ErrorCallback" class="idlType"><code>ErrorCallback</code></a></code></td><td class="prmNullFalse">?</td><td class="prmOptTrue">?</td><td class="prmDesc">
                A callback that is called when errors happen.
              </td></tr></table><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a>void</a></code></div></dd><dt id="widl-Entry-getParent"><code>getParent</code></dt><dd>
            Look up the parent DirectoryEntry containing this Entry.  If this
            Entry is the root of its filesystem, its parent is itself.
            
          <table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">successCallback</td><td class="prmType"><code><a href="#idl-def-EntryCallback" class="idlType"><code>EntryCallback</code></a></code></td><td class="prmNullFalse">?</td><td class="prmOptFalse">?</td><td class="prmDesc">
                A callback that is called to return the parent Entry.
              </td></tr><tr><td class="prmName">errorCallback</td><td class="prmType"><code><a href="#idl-def-ErrorCallback" class="idlType"><code>ErrorCallback</code></a></code></td><td class="prmNullFalse">?</td><td class="prmOptTrue">?</td><td class="prmDesc">
                A callback that is called when errors happen.
              </td></tr></table><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a>void</a></code></div></dd><dt id="widl-Entry-moveTo"><code>moveTo</code></dt><dd>
            <p>
              Move an entry to a different location on the file system.
              It is an error to try to:
              </p><ul>
                <li>move a directory inside itself or to any child at any
                depth;</li>
                <li>move an entry into its parent if a name different from its
                current one isn't provided;</li>
                <li>move a file to a path occupied by a directory;</li>
                <li>move a directory to a path occupied by a file;</li>
                <li>move any element to a path occupied by a directory which is
                not empty.</li>
              </ul>
              A move of a file on top of an existing file <em class="rfc2119" title="must">must</em> attempt to
              delete and replace that file.
              A move of a directory on top of an existing empty directory <em class="rfc2119" title="must">must</em>
              attempt to delete and replace that directory.
            <p></p>
            
          <table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">parent</td><td class="prmType"><code><a href="#idl-def-DirectoryEntry" class="idlType"><code>DirectoryEntry</code></a></code></td><td class="prmNullFalse">?</td><td class="prmOptFalse">?</td><td class="prmDesc">
                The directory to which to move the entry.
              </td></tr><tr><td class="prmName">newName</td><td class="prmType"><code><a>DOMString</a></code></td><td class="prmNullFalse">?</td><td class="prmOptTrue">?</td><td class="prmDesc">
                The new name of the entry.  Defaults to the Entry's current name
                if unspecified.
              </td></tr><tr><td class="prmName">successCallback</td><td class="prmType"><code><a href="#idl-def-EntryCallback" class="idlType"><code>EntryCallback</code></a></code></td><td class="prmNullFalse">?</td><td class="prmOptTrue">?</td><td class="prmDesc">
                A callback that is called with the Entry for the new location.
              </td></tr><tr><td class="prmName">errorCallback</td><td class="prmType"><code><a href="#idl-def-ErrorCallback" class="idlType"><code>ErrorCallback</code></a></code></td><td class="prmNullFalse">?</td><td class="prmOptTrue">?</td><td class="prmDesc">
                A callback that is called when errors happen.
              </td></tr></table><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a>void</a></code></div></dd><dt id="widl-Entry-remove"><code>remove</code></dt><dd>
            <p>
              Deletes a file or directory.  It is an error to attempt to delete
              a directory that is not empty.  It is an error to attempt to
              delete the root directory of a filesystem.
            </p>
            
          <table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">successCallback</td><td class="prmType"><code><a href="#idl-def-VoidCallback" class="idlType"><code>VoidCallback</code></a></code></td><td class="prmNullFalse">?</td><td class="prmOptFalse">?</td><td class="prmDesc">
                A callback that is called on success.
              </td></tr><tr><td class="prmName">errorCallback</td><td class="prmType"><code><a href="#idl-def-ErrorCallback" class="idlType"><code>ErrorCallback</code></a></code></td><td class="prmNullFalse">?</td><td class="prmOptTrue">?</td><td class="prmDesc">
                A callback that is called when errors happen.
              </td></tr></table><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a>void</a></code></div></dd><dt id="widl-Entry-toURL"><code>toURL</code></dt><dd>
            <p>
              Returns a URL that can be used to identify this entry.
              Unlike the URN defined in [<cite><a class="bibref" rel="biblioentry" href="#bib-FILE-API">FILE-API</a></cite>], it has no specific
              expiration; as it describes a location on disk, it should be valid
              at least as long as that location exists.

              Users may supply <code>mimeType</code> in order to simulate the
              optional mime-type header associated with HTTP downloads.
            </p>
            
            <div class="issue">
              <p>
              Do we want to spec out the URL format/scheme?  It would be quite
              nice if these could be edited and manipulated easily, as with
              normal filesystem paths.
              </p>
              <p>
              How and where can these URLs be used?  Can they be interchangeable
              with online URLs for the same domain?
              </p>
              <p>
              Proposal currently under discussion:
              </p><ul>
                <li>Use a format such as
                  <code>filesystem:http://example.domain/persistent-or-temporary/path/to/file.html
                  </code>.</li>
                <li>URLs should be usable for anything that online URLs can be
                used for, whether they appear in online or filesystem-resident
                web pages.</li>
                <li>However, they can only be used by the origin that owns the
                filesystem.  No other origin can e.g. reference another origin's
                filesystem in an IMG tag.</li>
              </ul>
              <p></p>
            </div>
          <table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">mimeType</td><td class="prmType"><code><a>DOMString</a></code></td><td class="prmNullFalse">?</td><td class="prmOptTrue">?</td><td class="prmDesc">
                For a FileEntry, the mime type to be used to interpret the file,
                when loaded through this URL.
              </td></tr></table><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a>DOMString</a></code></div></dd></dl></div>
      </div>
      
      <div id="the-directoryentry-interface" class="section">
        <h3><span class="secno">5.3 </span>The <code>DirectoryEntry</code> interface</h3>
        <p>
          This interface represents a directory on a file system.
        </p>
        <pre class="idl"><span class="idlInterface" id="idl-def-DirectoryEntry">[<span class="extAttr">NoInterfaceObject</span>]
interface <span class="idlInterfaceID">DirectoryEntry</span> : <span class="idlSuperclass"><a href="#idl-def-Entry" class="idlType"><code>Entry</code></a></span> {
<span class="idlMethod">    <span class="idlMethType"><a href="#idl-def-DirectoryReader" class="idlType"><code>DirectoryReader</code></a></span> <span class="idlMethName"><a href="#widl-DirectoryEntry-createReader">createReader</a></span> ();</span>
<span class="idlMethod">    <span class="idlMethType"><a>void</a></span>            <span class="idlMethName"><a href="#widl-DirectoryEntry-getFile">getFile</a></span> (<span class="idlParam"><span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">path</span></span>, <span class="idlParam">optional <span class="idlParamType"><a href="#idl-def-Flags" class="idlType"><code>Flags</code></a></span> <span class="idlParamName">options</span></span>, <span class="idlParam">optional <span class="idlParamType"><a href="#idl-def-EntryCallback" class="idlType"><code>EntryCallback</code></a></span> <span class="idlParamName">successCallback</span></span>, <span class="idlParam">optional <span class="idlParamType"><a href="#idl-def-ErrorCallback" class="idlType"><code>ErrorCallback</code></a></span> <span class="idlParamName">errorCallback</span></span>);</span>
<span class="idlMethod">    <span class="idlMethType"><a>void</a></span>            <span class="idlMethName"><a href="#widl-DirectoryEntry-getDirectory">getDirectory</a></span> (<span class="idlParam"><span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">path</span></span>, <span class="idlParam">optional <span class="idlParamType"><a href="#idl-def-Flags" class="idlType"><code>Flags</code></a></span> <span class="idlParamName">options</span></span>, <span class="idlParam">optional <span class="idlParamType"><a href="#idl-def-EntryCallback" class="idlType"><code>EntryCallback</code></a></span> <span class="idlParamName">successCallback</span></span>, <span class="idlParam">optional <span class="idlParamType"><a href="#idl-def-ErrorCallback" class="idlType"><code>ErrorCallback</code></a></span> <span class="idlParamName">errorCallback</span></span>);</span>
<span class="idlMethod">    <span class="idlMethType"><a>void</a></span>            <span class="idlMethName"><a href="#widl-DirectoryEntry-removeRecursively">removeRecursively</a></span> (<span class="idlParam"><span class="idlParamType"><a href="#idl-def-VoidCallback" class="idlType"><code>VoidCallback</code></a></span> <span class="idlParamName">successCallback</span></span>, <span class="idlParam">optional <span class="idlParamType"><a href="#idl-def-ErrorCallback" class="idlType"><code>ErrorCallback</code></a></span> <span class="idlParamName">errorCallback</span></span>);</span>
};</span>
</pre><div id="methods-3" class="section"><h4><span class="secno">5.3.1 </span>Methods</h4><dl class="methods"><dt id="widl-DirectoryEntry-createReader"><code>createReader</code></dt><dd>
            <p>
              Creates a new DirectoryReader to read Entries from this Directory.
            </p>
          <div><em>No parameters.</em></div><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a href="#idl-def-DirectoryReader" class="idlType"><code>DirectoryReader</code></a></code></div></dd><dt id="widl-DirectoryEntry-getDirectory"><code>getDirectory</code></dt><dd>
            <p>
              Creates or looks up a directory.
            </p>
            
          <table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">path</td><td class="prmType"><code><a>DOMString</a></code></td><td class="prmNullFalse">?</td><td class="prmOptFalse">?</td><td class="prmDesc">
                Either an <a href="#dfn-absolute-path" class="internalDFN">absolute path</a> or a <a href="#dfn-relative-path" class="internalDFN">relative path</a> from
                this DirectoryEntry to the directory to be looked up or created.
                It is an error to attempt to create a directory whose immediate
                parent does not yet exist.
              </td></tr><tr><td class="prmName">options</td><td class="prmType"><code><a href="#idl-def-Flags" class="idlType"><code>Flags</code></a></code></td><td class="prmNullFalse">?</td><td class="prmOptTrue">?</td><td class="prmDesc">
                <ul>
                  <li>If <code>create</code> and <code>exclusive</code> are both
                  true and the path already exists, getDirectory <em class="rfc2119" title="must">must</em> fail.</li>
                  <li>If <code>create</code> is true, the path doesn't exist,
                  and no other error occurs, getDirectory <em class="rfc2119" title="must">must</em> create and return
                  a corresponding DirectoryEntry.</li>
                  <li>If <code>create</code> is not true and the path doesn't
                  exist, getDirectory <em class="rfc2119" title="must">must</em> fail.</li>
                  <li>If <code>create</code> is not true and the path exists,
                  but is a file, getDirectory <em class="rfc2119" title="must">must</em> fail.</li>
                  <li>Otherwise, if no other error occurs, getDirectory <em class="rfc2119" title="must">must</em>
                  return a DirectoryEntry corresponding to path.</li>
                </ul>
              </td></tr><tr><td class="prmName">successCallback</td><td class="prmType"><code><a href="#idl-def-EntryCallback" class="idlType"><code>EntryCallback</code></a></code></td><td class="prmNullFalse">?</td><td class="prmOptTrue">?</td><td class="prmDesc">
                A callback that is called to return the DirectoryEntry selected
                or created.
              </td></tr><tr><td class="prmName">errorCallback</td><td class="prmType"><code><a href="#idl-def-ErrorCallback" class="idlType"><code>ErrorCallback</code></a></code></td><td class="prmNullFalse">?</td><td class="prmOptTrue">?</td><td class="prmDesc">
                A callback that is called when errors happen.
              </td></tr></table><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a>void</a></code></div></dd><dt id="widl-DirectoryEntry-getFile"><code>getFile</code></dt><dd>
            <p>
              Creates or looks up a file.
            </p>
            
          <table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">path</td><td class="prmType"><code><a>DOMString</a></code></td><td class="prmNullFalse">?</td><td class="prmOptFalse">?</td><td class="prmDesc">
                Either an <a href="#dfn-absolute-path" class="internalDFN">absolute path</a> or a <a href="#dfn-relative-path" class="internalDFN">relative path</a> from
                this DirectoryEntry to the file to be looked up or created.  It
                is an error to attempt to create a file whose immediate parent
                does not yet exist.
              </td></tr><tr><td class="prmName">options</td><td class="prmType"><code><a href="#idl-def-Flags" class="idlType"><code>Flags</code></a></code></td><td class="prmNullFalse">?</td><td class="prmOptTrue">?</td><td class="prmDesc">
                <ul>
                  <li>If <code>create</code> and <code>exclusive</code> are both
                  true, and the path already exists, getFile <em class="rfc2119" title="must">must</em> fail.</li>
                  <li>If <code>create</code> is true, the path doesn't exist,
                  and no other error occurs, getFile <em class="rfc2119" title="must">must</em> create it as a
                  zero-length file and return a corresponding FileEntry.</li>
                  <li>If <code>create</code> is not true and the path doesn't
                  exist, getFile <em class="rfc2119" title="must">must</em> fail.</li>
                  <li>If <code>create</code> is not true and the path exists,
                  but is a directory, getFile <em class="rfc2119" title="must">must</em> fail.</li>
                  <li>Otherwise, if no other error occurs, getFile <em class="rfc2119" title="must">must</em>
                  return a FileEntry corresponding to path.</li>
                </ul>
              </td></tr><tr><td class="prmName">successCallback</td><td class="prmType"><code><a href="#idl-def-EntryCallback" class="idlType"><code>EntryCallback</code></a></code></td><td class="prmNullFalse">?</td><td class="prmOptTrue">?</td><td class="prmDesc">
                A callback that is called to return the File selected or
                created.
              </td></tr><tr><td class="prmName">errorCallback</td><td class="prmType"><code><a href="#idl-def-ErrorCallback" class="idlType"><code>ErrorCallback</code></a></code></td><td class="prmNullFalse">?</td><td class="prmOptTrue">?</td><td class="prmDesc">
                A callback that is called when errors happen.
              </td></tr></table><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a>void</a></code></div></dd><dt id="widl-DirectoryEntry-removeRecursively"><code>removeRecursively</code></dt><dd>
            <p>
              Deletes a directory and all of its contents, if any.  In the event
              of an error [e.g. trying to delete a directory that contains a
              file that cannot be removed], some of the contents of the
              directory <em class="rfc2119" title="may">may</em> be deleted.  It is an error to attempt to delete the
              root directory of a filesystem.
            </p>
            
          <table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">successCallback</td><td class="prmType"><code><a href="#idl-def-VoidCallback" class="idlType"><code>VoidCallback</code></a></code></td><td class="prmNullFalse">?</td><td class="prmOptFalse">?</td><td class="prmDesc">
                A callback that is called on success.
              </td></tr><tr><td class="prmName">errorCallback</td><td class="prmType"><code><a href="#idl-def-ErrorCallback" class="idlType"><code>ErrorCallback</code></a></code></td><td class="prmNullFalse">?</td><td class="prmOptTrue">?</td><td class="prmDesc">
                A callback that is called when errors happen.
              </td></tr></table><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a>void</a></code></div></dd></dl></div>
      </div>
      
      <div id="the-directoryreader-interface" class="section">
        <h3><span class="secno">5.4 </span>The <code>DirectoryReader</code> interface</h3>
        <p>
          This interface lets a user list files and directories in a directory.
          If there are no additions to or deletions from a directory between the
          first and last call to readEntries, and no errors occur, then:
          </p><ul>
            <li>A series of calls to readEntries <em class="rfc2119" title="must">must</em> return each entry in the
            directory exactly once.</li>
            <li>Once all entries have been returned, the next call to
            readEntries <em class="rfc2119" title="must">must</em> produce an empty array.</li>
            <li>If not all entries have been returned, the array produced by
            readEntries <em class="rfc2119" title="must not">must not</em> be empty.</li>
            <li>The entries produced by readEntries <em class="rfc2119" title="must not">must not</em> include the
            directory itself ["."] or its parent [".."].</li>
          </ul>
        <p></p>
        <pre class="idl"><span class="idlInterface" id="idl-def-DirectoryReader">[<span class="extAttr">NoInterfaceObject</span>]
interface <span class="idlInterfaceID">DirectoryReader</span> {
<span class="idlMethod">    <span class="idlMethType"><a>void</a></span> <span class="idlMethName"><a href="#widl-DirectoryReader-readEntries">readEntries</a></span> (<span class="idlParam"><span class="idlParamType"><a href="#idl-def-EntriesCallback" class="idlType"><code>EntriesCallback</code></a></span> <span class="idlParamName">successCallback</span></span>, <span class="idlParam">optional <span class="idlParamType"><a href="#idl-def-ErrorCallback" class="idlType"><code>ErrorCallback</code></a></span> <span class="idlParamName">errorCallback</span></span>);</span>
};</span>
</pre><div id="methods-4" class="section"><h4><span class="secno">5.4.1 </span>Methods</h4><dl class="methods"><dt id="widl-DirectoryReader-readEntries"><code>readEntries</code></dt><dd>
            <p>
              Read the next block of entries from this directory.
            </p>
            
          <table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">successCallback</td><td class="prmType"><code><a href="#idl-def-EntriesCallback" class="idlType"><code>EntriesCallback</code></a></code></td><td class="prmNullFalse">?</td><td class="prmOptFalse">?</td><td class="prmDesc">
                Called once per successful call to readEntries to deliver the
                next previously-unreported set of Entries in the associated
                Directory.  If all Entries have already been returned from
                previous invocations of readEntries, successCallback <em class="rfc2119" title="must">must</em> be
                called with a zero-length array as an argument.
              </td></tr><tr><td class="prmName">errorCallback</td><td class="prmType"><code><a href="#idl-def-ErrorCallback" class="idlType"><code>ErrorCallback</code></a></code></td><td class="prmNullFalse">?</td><td class="prmOptTrue">?</td><td class="prmDesc">
                A callback indicating that there was an error reading from the
                Directory.
              </td></tr></table><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a>void</a></code></div></dd></dl></div>
      </div>

      <div id="the-fileentry-interface" class="section">
        <h3><span class="secno">5.5 </span>The <code>FileEntry</code> interface</h3>
        <p>
          This interface represents a file on a file system.
        </p>
        <pre class="idl"><span class="idlInterface" id="idl-def-FileEntry">[<span class="extAttr">NoInterfaceObject</span>]
interface <span class="idlInterfaceID">FileEntry</span> : <span class="idlSuperclass"><a href="#idl-def-Entry" class="idlType"><code>Entry</code></a></span> {
<span class="idlMethod">    <span class="idlMethType"><a>void</a></span> <span class="idlMethName"><a href="#widl-FileEntry-createWriter">createWriter</a></span> (<span class="idlParam"><span class="idlParamType"><a href="#idl-def-FileWriterCallback" class="idlType"><code>FileWriterCallback</code></a></span> <span class="idlParamName">successCallback</span></span>, <span class="idlParam">optional <span class="idlParamType"><a href="#idl-def-ErrorCallback" class="idlType"><code>ErrorCallback</code></a></span> <span class="idlParamName">errorCallback</span></span>);</span>
<span class="idlMethod">    <span class="idlMethType"><a>void</a></span> <span class="idlMethName"><a href="#widl-FileEntry-file">file</a></span> (<span class="idlParam"><span class="idlParamType"><a href="#idl-def-FileCallback" class="idlType"><code>FileCallback</code></a></span> <span class="idlParamName">successCallback</span></span>, <span class="idlParam">optional <span class="idlParamType"><a href="#idl-def-ErrorCallback" class="idlType"><code>ErrorCallback</code></a></span> <span class="idlParamName">errorCallback</span></span>);</span>
};</span>
</pre><div id="methods-5" class="section"><h4><span class="secno">5.5.1 </span>Methods</h4><dl class="methods"><dt id="widl-FileEntry-createWriter"><code>createWriter</code></dt><dd>
            <p>
              Creates a new <code>FileWriter</code> associated with the file
              that this <code>FileEntry</code> represents.
            </p>
            
          <table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">successCallback</td><td class="prmType"><code><a href="#idl-def-FileWriterCallback" class="idlType"><code>FileWriterCallback</code></a></code></td><td class="prmNullFalse">?</td><td class="prmOptFalse">?</td><td class="prmDesc">
                A callback that is called with the new <a>FileWriter</a>.
              </td></tr><tr><td class="prmName">errorCallback</td><td class="prmType"><code><a href="#idl-def-ErrorCallback" class="idlType"><code>ErrorCallback</code></a></code></td><td class="prmNullFalse">?</td><td class="prmOptTrue">?</td><td class="prmDesc">
                A callback that is called when errors happen.
              </td></tr></table><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a>void</a></code></div></dd><dt id="widl-FileEntry-file"><code>file</code></dt><dd>
            <p>
              Returns a <code>File</code> that represents the current state of
              the file that this <code>FileEntry</code> represents.
            </p>
            
          <table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">successCallback</td><td class="prmType"><code><a href="#idl-def-FileCallback" class="idlType"><code>FileCallback</code></a></code></td><td class="prmNullFalse">?</td><td class="prmOptFalse">?</td><td class="prmDesc">
                A callback that is called with the new <a>FileWriter</a>.
              </td></tr><tr><td class="prmName">errorCallback</td><td class="prmType"><code><a href="#idl-def-ErrorCallback" class="idlType"><code>ErrorCallback</code></a></code></td><td class="prmNullFalse">?</td><td class="prmOptTrue">?</td><td class="prmDesc">
                A callback that is called when errors happen.
              </td></tr></table><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a>void</a></code></div></dd></dl></div>
      </div>
      
      <div id="callbacks" class="section">
        <h3><span class="secno">5.6 </span>Callbacks</h3>
        <p>
          Several calls in this API are asynchronous, and use callbacks.
        </p>

        <div id="the-filesystemcallback-interface" class="section">
          <h4><span class="secno">5.6.1 </span>The <code>FileSystemCallback</code> interface</h4>
          <p>
            When <code>requestFileSystem()</code> succeeds, the following
            callback is made:
          </p>
          <pre class="idl"><span class="idlInterface" id="idl-def-FileSystemCallback">[<span class="extAttr">NoInterfaceObject, Callback=FunctionOnly</span>]
interface <span class="idlInterfaceID">FileSystemCallback</span> {
<span class="idlMethod">    <span class="idlMethType"><a>void</a></span> <span class="idlMethName"><a href="#widl-FileSystemCallback-handleEvent">handleEvent</a></span> (<span class="idlParam"><span class="idlParamType"><a href="#idl-def-FileSystem" class="idlType"><code>FileSystem</code></a></span> <span class="idlParamName">filesystem</span></span>);</span>
};</span>
</pre><div id="methods-6" class="section"><h5><span class="secno">5.6.1.1 </span>Methods</h5><dl class="methods"><dt id="widl-FileSystemCallback-handleEvent"><code>handleEvent</code></dt><dd>
              <p>
                The file system was successfully obtained.
              </p>
              
            <table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">filesystem</td><td class="prmType"><code><a href="#idl-def-FileSystem" class="idlType"><code>FileSystem</code></a></code></td><td class="prmNullFalse">?</td><td class="prmOptFalse">?</td><td class="prmDesc">
                  The file systems to which the app is granted access.
                </td></tr></table><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a>void</a></code></div></dd></dl></div>
        </div>

        <div id="the-entrycallback-interface" class="section">
          <h4><span class="secno">5.6.2 </span>The <code>EntryCallback</code> interface</h4>
          <p>
            This interface is the callback used to look up Entry objects.
          </p>
          <pre class="idl"><span class="idlInterface" id="idl-def-EntryCallback">[<span class="extAttr">NoInterfaceObject, Callback=FunctionOnly</span>]
interface <span class="idlInterfaceID">EntryCallback</span> {
<span class="idlMethod">    <span class="idlMethType"><a>void</a></span> <span class="idlMethName"><a href="#widl-EntryCallback-handleEvent">handleEvent</a></span> (<span class="idlParam"><span class="idlParamType"><a href="#idl-def-Entry" class="idlType"><code>Entry</code></a></span> <span class="idlParamName">entry</span></span>);</span>
};</span>
</pre><div id="methods-7" class="section"><h5><span class="secno">5.6.2.1 </span>Methods</h5><dl class="methods"><dt id="widl-EntryCallback-handleEvent"><code>handleEvent</code></dt><dd>
              Used to supply an Entry as a response to a user query.
            <table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">entry</td><td class="prmType"><code><a href="#idl-def-Entry" class="idlType"><code>Entry</code></a></code></td><td class="prmNullFalse">?</td><td class="prmOptFalse">?</td><td class="prmDesc"></td></tr></table><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a>void</a></code></div></dd></dl></div>
        </div>

        <div id="the-entriescallback-interface" class="section">
          <h4><span class="secno">5.6.3 </span>The <code>EntriesCallback</code> interface</h4>
          <p>
            When <code>readEntries()</code> succeeds, the following callback is
            made.
          </p>
          <pre class="idl"><span class="idlInterface" id="idl-def-EntriesCallback">[<span class="extAttr">NoInterfaceObject, Callback=FunctionOnly</span>]
interface <span class="idlInterfaceID">EntriesCallback</span> {
<span class="idlMethod">    <span class="idlMethType"><a>void</a></span> <span class="idlMethName"><a href="#widl-EntriesCallback-handleEvent">handleEvent</a></span> (<span class="idlParam"><span class="idlParamType"><a href="#idl-def-Entry" class="idlType"><code>Entry</code></a>[]</span> <span class="idlParamName">entries</span></span>);</span>
};</span>
</pre><div id="methods-8" class="section"><h5><span class="secno">5.6.3.1 </span>Methods</h5><dl class="methods"><dt id="widl-EntriesCallback-handleEvent"><code>handleEvent</code></dt><dd>
              Used to supply an array of Entries as a response to a user query.
            <table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">entries</td><td class="prmType"><code><a href="#idl-def-Entry" class="idlType"><code>Entry</code></a>[]</code></td><td class="prmNullFalse">?</td><td class="prmOptFalse">?</td><td class="prmDesc"></td></tr></table><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a>void</a></code></div></dd></dl></div>
        </div>

        <div id="the-metadatacallback-interface" class="section">
          <h4><span class="secno">5.6.4 </span>The <code>MetadataCallback</code> interface</h4>
          <p>
            This interface is the callback used to look up file and directory
            metadata.
          </p>
          <pre class="idl"><span class="idlInterface" id="idl-def-MetadataCallback">[<span class="extAttr">NoInterfaceObject, Callback=FunctionOnly</span>]
interface <span class="idlInterfaceID">MetadataCallback</span> {
<span class="idlMethod">    <span class="idlMethType"><a>void</a></span> <span class="idlMethName"><a href="#widl-MetadataCallback-handleEvent">handleEvent</a></span> (<span class="idlParam"><span class="idlParamType"><a href="#idl-def-Metadata" class="idlType"><code>Metadata</code></a></span> <span class="idlParamName">metadata</span></span>);</span>
};</span>
</pre><div id="methods-9" class="section"><h5><span class="secno">5.6.4.1 </span>Methods</h5><dl class="methods"><dt id="widl-MetadataCallback-handleEvent"><code>handleEvent</code></dt><dd>
              <p>
                Used to supply file or directory metadata as a response to a
                user query.
              </p>
            <table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">metadata</td><td class="prmType"><code><a href="#idl-def-Metadata" class="idlType"><code>Metadata</code></a></code></td><td class="prmNullFalse">?</td><td class="prmOptFalse">?</td><td class="prmDesc"></td></tr></table><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a>void</a></code></div></dd></dl></div>
        </div>

        <div id="the-filewritercallback-interface" class="section">
          <h4><span class="secno">5.6.5 </span>The <code>FileWriterCallback</code> interface</h4>
          <p>
          This interface is the callback used to create a
          <code>FileWriter</code>.
          </p>
          <pre class="idl"><span class="idlInterface" id="idl-def-FileWriterCallback">[<span class="extAttr">NoInterfaceObject, Callback=FunctionOnly</span>]
interface <span class="idlInterfaceID">FileWriterCallback</span> {
<span class="idlMethod">    <span class="idlMethType"><a>void</a></span> <span class="idlMethName"><a href="#widl-FileWriterCallback-handleEvent">handleEvent</a></span> (<span class="idlParam"><span class="idlParamType"><a>FileWriter</a></span> <span class="idlParamName">fileWriter</span></span>);</span>
};</span>
</pre><div id="methods-10" class="section"><h5><span class="secno">5.6.5.1 </span>Methods</h5><dl class="methods"><dt id="widl-FileWriterCallback-handleEvent"><code>handleEvent</code></dt><dd>
              <p>
              Used to supply a <code>FileWriter</code> as a response to a user
              query.
              </p>
            <table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">fileWriter</td><td class="prmType"><code><a>FileWriter</a></code></td><td class="prmNullFalse">?</td><td class="prmOptFalse">?</td><td class="prmDesc"></td></tr></table><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a>void</a></code></div></dd></dl></div>
        </div>

        <div id="the-filecallback-interface" class="section">
          <h4><span class="secno">5.6.6 </span>The <code>FileCallback</code> interface</h4>
          <p>
          This interface is the callback used to obtain a <code>File</code>.
          </p>
          <pre class="idl"><span class="idlInterface" id="idl-def-FileCallback">[<span class="extAttr">NoInterfaceObject, Callback=FunctionOnly</span>]
interface <span class="idlInterfaceID">FileCallback</span> {
<span class="idlMethod">    <span class="idlMethType"><a>void</a></span> <span class="idlMethName"><a href="#widl-FileCallback-handleEvent">handleEvent</a></span> (<span class="idlParam"><span class="idlParamType"><a>File</a></span> <span class="idlParamName">file</span></span>);</span>
};</span>
</pre><div id="methods-11" class="section"><h5><span class="secno">5.6.6.1 </span>Methods</h5><dl class="methods"><dt id="widl-FileCallback-handleEvent"><code>handleEvent</code></dt><dd>
              <p>
              Used to supply a <code>File</code> as a response to a user query.
              </p>
            <table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">file</td><td class="prmType"><code><a>File</a></code></td><td class="prmNullFalse">?</td><td class="prmOptFalse">?</td><td class="prmDesc"></td></tr></table><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a>void</a></code></div></dd></dl></div>
        </div>

        <div id="the-voidcallback-interface" class="section">
          <h4><span class="secno">5.6.7 </span>The <code>VoidCallback</code> interface</h4>
          <p>
            This interface is the generic callback used to indicate success of
            an asynchronous method.
          </p>
          <pre class="idl"><span class="idlInterface" id="idl-def-VoidCallback">[<span class="extAttr">NoInterfaceObject, Callback=FunctionOnly</span>]
interface <span class="idlInterfaceID">VoidCallback</span> {
<span class="idlMethod">    <span class="idlMethType"><a>void</a></span> <span class="idlMethName"><a href="#widl-VoidCallback-handleEvent">handleEvent</a></span> ();</span>
};</span>
</pre><div id="methods-12" class="section"><h5><span class="secno">5.6.7.1 </span>Methods</h5><dl class="methods"><dt id="widl-VoidCallback-handleEvent"><code>handleEvent</code></dt><dd>
            <div><em>No parameters.</em></div><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a>void</a></code></div></dd></dl></div>
        </div>

        <div id="the-errorcallback-interface" class="section">
          <h4><span class="secno">5.6.8 </span>The <code>ErrorCallback</code> interface</h4>
          <p>
            When an error occurs, the following callback is made:
          </p>
          <pre class="idl"><span class="idlInterface" id="idl-def-ErrorCallback">[<span class="extAttr">NoInterfaceObject, Callback=FunctionOnly</span>]
interface <span class="idlInterfaceID">ErrorCallback</span> {
<span class="idlMethod">    <span class="idlMethType"><a>void</a></span> <span class="idlMethName"><a href="#widl-ErrorCallback-handleEvent">handleEvent</a></span> (<span class="idlParam"><span class="idlParamType"><a href="#idl-def-FileError" class="idlType"><code>FileError</code></a></span> <span class="idlParamName">err</span></span>);</span>
};</span>
</pre><div id="methods-13" class="section"><h5><span class="secno">5.6.8.1 </span>Methods</h5><dl class="methods"><dt id="widl-ErrorCallback-handleEvent"><code>handleEvent</code></dt><dd>
              <p>
                There was an error with the request. Details are provided by the
                <a href="#idl-def-FileError" class="idlType"><code>FileError</code></a> parameter.
              </p>
              
            <table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">err</td><td class="prmType"><code><a href="#idl-def-FileError" class="idlType"><code>FileError</code></a></code></td><td class="prmNullFalse">?</td><td class="prmOptFalse">?</td><td class="prmDesc">
                  The error that was generated.
                </td></tr></table><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a>void</a></code></div></dd></dl></div>
        </div>
      </div>
    </div>
    <div id="the-synchronous-filesystem-interface" class="section">
      <!--OddPage--><h2><span class="secno">6. </span>The synchronous filesystem interface</h2>
      <div id="the-filesystemsync-interface" class="section">
        <h3><span class="secno">6.1 </span>The <code>FileSystemSync</code> interface</h3>
        <p>
          This interface represents a file system.
        </p>
        <pre class="idl"><span class="idlInterface" id="idl-def-FileSystemSync">[<span class="extAttr">NoInterfaceObject</span>]
interface <span class="idlInterfaceID">FileSystemSync</span> {
<span class="idlAttribute">    readonly attribute <span class="idlAttrType"><a>DOMString</a></span>          <span class="idlAttrName"><a href="#widl-FileSystemSync-name">name</a></span>;</span>
<span class="idlAttribute">    readonly attribute <span class="idlAttrType"><a href="#idl-def-DirectoryEntrySync" class="idlType"><code>DirectoryEntrySync</code></a></span> <span class="idlAttrName"><a href="#widl-FileSystemSync-root">root</a></span>;</span>
};</span>
</pre><div id="attributes-4" class="section"><h4><span class="secno">6.1.1 </span>Attributes</h4><dl class="attributes"><dt id="widl-FileSystemSync-name"><code>name</code> of type <span class="idlAttrType"><a>DOMString</a></span>, readonly</dt><dd>
            This is the name of the file system.  The specifics of naming
            filesystems is unspecified, but a name <em class="rfc2119" title="must">must</em> be unique across the
            list of exposed file systems.
          <div><em>No exceptions.</em></div></dd><dt id="widl-FileSystemSync-root"><code>root</code> of type <span class="idlAttrType"><a href="#idl-def-DirectoryEntrySync" class="idlType"><code>DirectoryEntrySync</code></a></span>, readonly</dt><dd>
            The root directory of the file system.
          <div><em>No exceptions.</em></div></dd></dl></div>
      </div>

      <div id="the-entrysync-interface" class="section">
        <h3><span class="secno">6.2 </span>The <code>EntrySync</code> interface</h3>
        <p>
          An abstract interface representing entries in a file system, each of
          which may be a <a href="#idl-def-FileEntrySync" class="idlType"><code>FileEntrySync</code></a> or <a href="#idl-def-DirectoryEntrySync" class="idlType"><code>DirectoryEntrySync</code></a>.
          </p><div class="issue">
            Some have requested support for archive files.  I've not required
            that, but I've left space for it by not ruling out having both
            isFile and isDirectory be true.  I welcome comments on this
            approach.
          </div>
        <p></p>
        <pre class="idl"><span class="idlInterface" id="idl-def-EntrySync">[<span class="extAttr">NoInterfaceObject</span>]
interface <span class="idlInterfaceID">EntrySync</span> {
<span class="idlAttribute">    readonly attribute <span class="idlAttrType"><a>boolean</a></span>        <span class="idlAttrName"><a href="#widl-EntrySync-isFile">isFile</a></span>;</span>
<span class="idlAttribute">    readonly attribute <span class="idlAttrType"><a>boolean</a></span>        <span class="idlAttrName"><a href="#widl-EntrySync-isDirectory">isDirectory</a></span>;</span>
<span class="idlMethod">    <span class="idlMethType"><a href="#idl-def-Metadata" class="idlType"><code>Metadata</code></a></span>           <span class="idlMethName"><a href="#widl-EntrySync-getMetadata">getMetadata</a></span> () raises (<span class="idlRaises"><a href="#idl-def-FileException" class="idlType"><code>FileException</code></a></span>);</span>
<span class="idlAttribute">    readonly attribute <span class="idlAttrType"><a>DOMString</a></span>      <span class="idlAttrName"><a href="#widl-EntrySync-name">name</a></span>;</span>
<span class="idlAttribute">    readonly attribute <span class="idlAttrType"><a>DOMString</a></span>      <span class="idlAttrName"><a href="#widl-EntrySync-fullPath">fullPath</a></span>;</span>
<span class="idlAttribute">    readonly attribute <span class="idlAttrType"><a href="#idl-def-FileSystemSync" class="idlType"><code>FileSystemSync</code></a></span> <span class="idlAttrName"><a href="#widl-EntrySync-filesystem">filesystem</a></span>;</span>
<span class="idlMethod">    <span class="idlMethType"><a href="#idl-def-EntrySync" class="idlType"><code>EntrySync</code></a></span>          <span class="idlMethName"><a href="#widl-EntrySync-moveTo">moveTo</a></span> (<span class="idlParam"><span class="idlParamType"><a href="#idl-def-DirectoryEntrySync" class="idlType"><code>DirectoryEntrySync</code></a></span> <span class="idlParamName">parent</span></span>, <span class="idlParam">optional <span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">newName</span></span>) raises (<span class="idlRaises"><a href="#idl-def-FileException" class="idlType"><code>FileException</code></a></span>);</span>
<span class="idlMethod">    <span class="idlMethType"><a href="#idl-def-EntrySync" class="idlType"><code>EntrySync</code></a></span>          <span class="idlMethName"><a href="#widl-EntrySync-copyTo">copyTo</a></span> (<span class="idlParam"><span class="idlParamType"><a href="#idl-def-DirectoryEntrySync" class="idlType"><code>DirectoryEntrySync</code></a></span> <span class="idlParamName">parent</span></span>, <span class="idlParam">optional <span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">newName</span></span>) raises (<span class="idlRaises"><a href="#idl-def-FileException" class="idlType"><code>FileException</code></a></span>);</span>
<span class="idlMethod">    <span class="idlMethType"><a>DOMString</a></span>          <span class="idlMethName"><a href="#widl-EntrySync-toURL">toURL</a></span> (<span class="idlParam">optional <span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">mimeType</span></span>);</span>
<span class="idlMethod">    <span class="idlMethType"><a>void</a></span>               <span class="idlMethName"><a href="#widl-EntrySync-remove">remove</a></span> () raises (<span class="idlRaises"><a href="#idl-def-FileException" class="idlType"><code>FileException</code></a></span>);</span>
<span class="idlMethod">    <span class="idlMethType"><a href="#idl-def-DirectoryEntrySync" class="idlType"><code>DirectoryEntrySync</code></a></span> <span class="idlMethName"><a href="#widl-EntrySync-getParent">getParent</a></span> ();</span>
};</span>
</pre><div id="attributes-5" class="section"><h4><span class="secno">6.2.1 </span>Attributes</h4><dl class="attributes"><dt id="widl-EntrySync-filesystem"><code>filesystem</code> of type <span class="idlAttrType"><a href="#idl-def-FileSystemSync" class="idlType"><code>FileSystemSync</code></a></span>, readonly</dt><dd>
            The file system on which the entry resides.
          <div><em>No exceptions.</em></div></dd><dt id="widl-EntrySync-fullPath"><code>fullPath</code> of type <span class="idlAttrType"><a>DOMString</a></span>, readonly</dt><dd>
            The full <a href="#dfn-absolute-path" class="internalDFN">absolute path</a> from the root to the entry.
          <div><em>No exceptions.</em></div></dd><dt id="widl-EntrySync-isDirectory"><code>isDirectory</code> of type <span class="idlAttrType"><a>boolean</a></span>, readonly</dt><dd>
            EntrySync is a directory.
          <div><em>No exceptions.</em></div></dd><dt id="widl-EntrySync-isFile"><code>isFile</code> of type <span class="idlAttrType"><a>boolean</a></span>, readonly</dt><dd>
            EntrySync is a file.
          <div><em>No exceptions.</em></div></dd><dt id="widl-EntrySync-name"><code>name</code> of type <span class="idlAttrType"><a>DOMString</a></span>, readonly</dt><dd>
            The name of the entry, excluding the path leading to it.
          <div><em>No exceptions.</em></div></dd></dl></div><div id="methods-14" class="section"><h4><span class="secno">6.2.2 </span>Methods</h4><dl class="methods"><dt id="widl-EntrySync-copyTo"><code>copyTo</code></dt><dd>
            <p>
              Copy an entry to a different location on the file system. It is an
              error to try to copy an entry inside itself at any depth if it is
              a directory, or to copy it into its parent if a name different
              from its current one isn't provided.
            </p>
            
            
          <table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">parent</td><td class="prmType"><code><a href="#idl-def-DirectoryEntrySync" class="idlType"><code>DirectoryEntrySync</code></a></code></td><td class="prmNullFalse">?</td><td class="prmOptFalse">?</td><td class="prmDesc">
                The directory to which to move the entry.
              </td></tr><tr><td class="prmName">newName</td><td class="prmType"><code><a>DOMString</a></code></td><td class="prmNullFalse">?</td><td class="prmOptTrue">?</td><td class="prmDesc">
                The new name of the entry.  Defaults to the EntrySync's current
                name if unspecified.
              </td></tr></table><table class="exceptions"><tr><th>Exception</th><th>Description</th></tr><tr><td class="excName"><a href="#idl-def-FileException" class="idlType"><code>FileException</code></a></td><td class="excDesc"><table class="exceptionCodes"><tr><td class="excCodeName"><code>ENCODING_ERR</code></td><td class="excCodeDesc">The name supplied was invalid.</td></tr><tr><td class="excCodeName"><code>NOT_FOUND_ERR</code></td><td class="excCodeDesc">The target directory does not exist.</td></tr><tr><td class="excCodeName"><code>INVALID_MODIFICATION_ERR</code></td><td class="excCodeDesc">The user attempted to copy an entry into its parent without
              changing its name, or attempted to copy a directory into a
              directory that it contains directly or indirectly.</td></tr><tr><td class="excCodeName"><code>NO_MODIFICATION_ALLOWED_ERR</code></td><td class="excCodeDesc">The target directory is not writable.</td></tr><tr><td class="excCodeName"><code>QUOTA_EXCEEDED_ERR</code></td><td class="excCodeDesc">The operation would cause the application to exceed its
              storage quota.</td></tr><tr><td class="excCodeName"><code>SECURITY_ERR</code></td><td class="excCodeDesc">The <a href="#dfn-user-agent" class="internalDFN">user agent</a> determined that it was not safe to carry
              out this action.</td></tr></table></td></tr></table><div><em>Return type: </em><code><a href="#idl-def-EntrySync" class="idlType"><code>EntrySync</code></a></code></div></dd><dt id="widl-EntrySync-getMetadata"><code>getMetadata</code></dt><dd>
            <p>
              Look up metadata about this entry.
            </p>
            
          <div><em>No parameters.</em></div><table class="exceptions"><tr><th>Exception</th><th>Description</th></tr><tr><td class="excName"><a href="#idl-def-FileException" class="idlType"><code>FileException</code></a></td><td class="excDesc"><table class="exceptionCodes"><tr><td class="excCodeName"><code>NOT_FOUND_ERR</code></td><td class="excCodeDesc">The entry no longer exists.</td></tr><tr><td class="excCodeName"><code>INVALID_STATE_ERR</code></td><td class="excCodeDesc">This FileSystemSync is no longer valid for some reason other
              than it having been deleted.</td></tr><tr><td class="excCodeName"><code>SECURITY_ERR</code></td><td class="excCodeDesc">The <a href="#dfn-user-agent" class="internalDFN">user agent</a> determined that it was not safe to carry
              out this action.</td></tr></table></td></tr></table><div><em>Return type: </em><code><a href="#idl-def-Metadata" class="idlType"><code>Metadata</code></a></code></div></dd><dt id="widl-EntrySync-getParent"><code>getParent</code></dt><dd>
            Look up the parent DirectoryEntrySync containing this Entry.  If
            this EntrySync is the root of its filesystem, its parent is itself.
          <div><em>No parameters.</em></div><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a href="#idl-def-DirectoryEntrySync" class="idlType"><code>DirectoryEntrySync</code></a></code></div></dd><dt id="widl-EntrySync-moveTo"><code>moveTo</code></dt><dd>
            <p>
              Move an entry to a different location on the file system.
              It is an error to try to:
              </p><ul>
                <li>move a directory inside itself or to any child at any
                depth;</li>
                <li>move an entry into its parent if a name different from its
                current one isn't provided;</li>
                <li>move a file to a path occupied by a directory;</li>
                <li>move a directory to a path occupied by a file;</li>
                <li>move any element to a path occupied by a directory which is
                not empty.</li>
              </ul>
              A move of a file on top of an existing file <em class="rfc2119" title="must">must</em> attempt to
              delete and replace that file.
              A move of a directory on top of an existing empty directory <em class="rfc2119" title="must">must</em>
              attempt to delete and replace that directory.
            <p></p>
            
            
          <table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">parent</td><td class="prmType"><code><a href="#idl-def-DirectoryEntrySync" class="idlType"><code>DirectoryEntrySync</code></a></code></td><td class="prmNullFalse">?</td><td class="prmOptFalse">?</td><td class="prmDesc">
                The directory to which to move the entry.
              </td></tr><tr><td class="prmName">newName</td><td class="prmType"><code><a>DOMString</a></code></td><td class="prmNullFalse">?</td><td class="prmOptTrue">?</td><td class="prmDesc">
                The new name of the entry.  Defaults to the EntrySync's current
                name if unspecified.
              </td></tr></table><table class="exceptions"><tr><th>Exception</th><th>Description</th></tr><tr><td class="excName"><a href="#idl-def-FileException" class="idlType"><code>FileException</code></a></td><td class="excDesc"><table class="exceptionCodes"><tr><td class="excCodeName"><code>ENCODING_ERR</code></td><td class="excCodeDesc">The name supplied was invalid.</td></tr><tr><td class="excCodeName"><code>NOT_FOUND_ERR</code></td><td class="excCodeDesc">The target directory does not exist.</td></tr><tr><td class="excCodeName"><code>INVALID_MODIFICATION_ERR</code></td><td class="excCodeDesc">The user attempted to move an entry into its parent without
              changing its name, or attempted to move a directory into a
              directory that it contains directly or indirectly.</td></tr><tr><td class="excCodeName"><code>NO_MODIFICATION_ALLOWED_ERR</code></td><td class="excCodeDesc">The either the source entry, its parent directory, or the
              target directory is not writable.</td></tr><tr><td class="excCodeName"><code>SECURITY_ERR</code></td><td class="excCodeDesc">The <a href="#dfn-user-agent" class="internalDFN">user agent</a> determined that it was not safe to carry
              out this action.</td></tr></table></td></tr></table><div><em>Return type: </em><code><a href="#idl-def-EntrySync" class="idlType"><code>EntrySync</code></a></code></div></dd><dt id="widl-EntrySync-remove"><code>remove</code></dt><dd>
            <p>
              Deletes a file or directory.  It is an error to attempt to delete
              a directory that is not empty.  It is an error to attempt to
              delete the root directory of a filesystem.
            </p>
            
          <div><em>No parameters.</em></div><table class="exceptions"><tr><th>Exception</th><th>Description</th></tr><tr><td class="excName"><a href="#idl-def-FileException" class="idlType"><code>FileException</code></a></td><td class="excDesc"><table class="exceptionCodes"><tr><td class="excCodeName"><code>NOT_FOUND_ERR</code></td><td class="excCodeDesc">The target directory does not exist.</td></tr><tr><td class="excCodeName"><code>INVALID_MODIFICATION_ERR</code></td><td class="excCodeDesc">The user attempted to remove a directory that was not
              empty.</td></tr><tr><td class="excCodeName"><code>NO_MODIFICATION_ALLOWED_ERR</code></td><td class="excCodeDesc">The target or its containing directory is not writable.</td></tr><tr><td class="excCodeName"><code>SECURITY_ERR</code></td><td class="excCodeDesc">The <a href="#dfn-user-agent" class="internalDFN">user agent</a> determined that it was not safe to carry
              out this action.</td></tr></table></td></tr></table><div><em>Return type: </em><code><a>void</a></code></div></dd><dt id="widl-EntrySync-toURL"><code>toURL</code></dt><dd>
            <p>
              Returns a URL that can be used to identify this entry.
              Unlike the URN defined in [<cite><a class="bibref" rel="biblioentry" href="#bib-FILE-API">FILE-API</a></cite>], it has no specific
              expiration; as it describes a location on disk, it should be valid
              at least as long as that location exists.

              Users may supply <code>mimeType</code> in order to simulate the
              optional mime-type header associated with HTTP downloads.
            </p>
            
            <div class="issue">
              <p>
              If we use the same opaque URL scheme as in [<cite><a class="bibref" rel="biblioentry" href="#bib-FILE-API">FILE-API</a></cite>], users
              won't be able to edit and generate URLs themselves.  On the other
              hand, it would prevent us from having to go to all the trouble of
              designing a new scheme, and it would simplify the use of the two
              APIs together.
              </p>
            </div>
          <table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">mimeType</td><td class="prmType"><code><a>DOMString</a></code></td><td class="prmNullFalse">?</td><td class="prmOptTrue">?</td><td class="prmDesc">
                For a FileEntry, the mime type to be used to interpret the file,
                when loaded through this URL.
              </td></tr></table><div><em>No exceptions.</em></div><div><em>Return type: </em><code><a>DOMString</a></code></div></dd></dl></div>
      </div>
      
      <div id="the-directoryentrysync-interface" class="section">
        <h3><span class="secno">6.3 </span>The <code>DirectoryEntrySync</code> interface</h3>
        <p>
          This interface represents a directory on a file system.
        </p>
        <pre class="idl"><span class="idlInterface" id="idl-def-DirectoryEntrySync">[<span class="extAttr">NoInterfaceObject</span>]
interface <span class="idlInterfaceID">DirectoryEntrySync</span> : <span class="idlSuperclass"><a href="#idl-def-EntrySync" class="idlType"><code>EntrySync</code></a></span> {
<span class="idlMethod">    <span class="idlMethType"><a href="#idl-def-DirectoryReaderSync" class="idlType"><code>DirectoryReaderSync</code></a></span> <span class="idlMethName"><a href="#widl-DirectoryEntrySync-createReader">createReader</a></span> () raises (<span class="idlRaises"><a href="#idl-def-FileException" class="idlType"><code>FileException</code></a></span>);</span>
<span class="idlMethod">    <span class="idlMethType"><a href="#idl-def-FileEntrySync" class="idlType"><code>FileEntrySync</code></a></span>       <span class="idlMethName"><a href="#widl-DirectoryEntrySync-getFile">getFile</a></span> (<span class="idlParam"><span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">path</span></span>, <span class="idlParam">optional <span class="idlParamType"><a href="#idl-def-Flags" class="idlType"><code>Flags</code></a></span> <span class="idlParamName">options</span></span>) raises (<span class="idlRaises"><a href="#idl-def-FileException" class="idlType"><code>FileException</code></a></span>);</span>
<span class="idlMethod">    <span class="idlMethType"><a href="#idl-def-DirectoryEntrySync" class="idlType"><code>DirectoryEntrySync</code></a></span>  <span class="idlMethName"><a href="#widl-DirectoryEntrySync-getDirectory">getDirectory</a></span> (<span class="idlParam"><span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">path</span></span>, <span class="idlParam">optional <span class="idlParamType"><a href="#idl-def-Flags" class="idlType"><code>Flags</code></a></span> <span class="idlParamName">options</span></span>) raises (<span class="idlRaises"><a href="#idl-def-FileException" class="idlType"><code>FileException</code></a></span>);</span>
<span class="idlMethod">    <span class="idlMethType"><a>void</a></span>                <span class="idlMethName"><a href="#widl-DirectoryEntrySync-removeRecursively">removeRecursively</a></span> () raises (<span class="idlRaises"><a href="#idl-def-FileException" class="idlType"><code>FileException</code></a></span>);</span>
};</span>
</pre><div id="methods-15" class="section"><h4><span class="secno">6.3.1 </span>Methods</h4><dl class="methods"><dt id="widl-DirectoryEntrySync-createReader"><code>createReader</code></dt><dd>
            <p>
              Creates a new DirectoryReaderSync to read EntrySyncs from this
              DirectorySync.
            </p>
            
          <div><em>No parameters.</em></div><table class="exceptions"><tr><th>Exception</th><th>Description</th></tr><tr><td class="excName"><a href="#idl-def-FileException" class="idlType"><code>FileException</code></a></td><td class="excDesc"><table class="exceptionCodes"><tr><td class="excCodeName"><code>NOT_FOUND_ERR</code></td><td class="excCodeDesc">The directory no longer exists.</td></tr><tr><td class="excCodeName"><code>SECURITY_ERR</code></td><td class="excCodeDesc">The <a href="#dfn-user-agent" class="internalDFN">user agent</a> determined that it was not safe to carry
              out this action.</td></tr></table></td></tr></table><div><em>Return type: </em><code><a href="#idl-def-DirectoryReaderSync" class="idlType"><code>DirectoryReaderSync</code></a></code></div></dd><dt id="widl-DirectoryEntrySync-getDirectory"><code>getDirectory</code></dt><dd>
            <p>
              Creates or looks up a directory.
            </p>
            
            
          <table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">path</td><td class="prmType"><code><a>DOMString</a></code></td><td class="prmNullFalse">?</td><td class="prmOptFalse">?</td><td class="prmDesc">
                Either an <a href="#dfn-absolute-path" class="internalDFN">absolute path</a> or a <a href="#dfn-relative-path" class="internalDFN">relative path</a> from
                this DirectoryEntrySync to the directory to be looked up or
                created.  It is an error to attempt to create a directory whose
                immediate parent does not yet exist.
              </td></tr><tr><td class="prmName">options</td><td class="prmType"><code><a href="#idl-def-Flags" class="idlType"><code>Flags</code></a></code></td><td class="prmNullFalse">?</td><td class="prmOptTrue">?</td><td class="prmDesc">
                <ul>
                  <li>If <code>create</code> and <code>exclusive</code> are both
                  true and the path already exists, getDirectory <em class="rfc2119" title="must">must</em> fail.</li>
                  <li>If <code>create</code> is true, the path doesn't exist,
                  and no other error occurs, getDirectory <em class="rfc2119" title="must">must</em> create and return
                  a corresponding DirectoryEntry.</li>
                  <li>If <code>create</code> is not true and the path doesn't
                  exist, getDirectory <em class="rfc2119" title="must">must</em> fail.</li>
                  <li>If <code>create</code> is not true and the path exists,
                  but is a file, getDirectory <em class="rfc2119" title="must">must</em> fail.</li>
                  <li>Otherwise, if no other error occurs, getDirectory <em class="rfc2119" title="must">must</em>
                  return a DirectoryEntrySync corresponding to path.</li>
                </ul>
              </td></tr></table><table class="exceptions"><tr><th>Exception</th><th>Description</th></tr><tr><td class="excName"><a href="#idl-def-FileException" class="idlType"><code>FileException</code></a></td><td class="excDesc"><table class="exceptionCodes"><tr><td class="excCodeName"><code>ENCODING_ERR</code></td><td class="excCodeDesc">The path was invalid.</td></tr><tr><td class="excCodeName"><code>NOT_FOUND_ERR</code></td><td class="excCodeDesc">The path was structurally correct, but refers to a resource
              that does not exist.</td></tr><tr><td class="excCodeName"><code>NO_MODIFICATION_ALLOWED_ERR</code></td><td class="excCodeDesc">The target directory is not writable.</td></tr><tr><td class="excCodeName"><code>PATH_EXISTS_ERR</code></td><td class="excCodeDesc">The user attempted to create a directory where an element
              already exists.
              </td></tr><tr><td class="excCodeName"><code>QUOTA_EXCEEDED_ERR</code></td><td class="excCodeDesc">The operation would cause the application to exceed its
              storage quota.</td></tr><tr><td class="excCodeName"><code>SECURITY_ERR</code></td><td class="excCodeDesc">The application does not have permission to access the
              element referred to by path.</td></tr><tr><td class="excCodeName"><code>TYPE_MISMATCH_ERR</code></td><td class="excCodeDesc">The path supplied exists, but is not a directory.</td></tr></table></td></tr></table><div><em>Return type: </em><code><a href="#idl-def-DirectoryEntrySync" class="idlType"><code>DirectoryEntrySync</code></a></code></div></dd><dt id="widl-DirectoryEntrySync-getFile"><code>getFile</code></dt><dd>
            <p>
              Creates or looks up a file.
            </p>
            
            
          <table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">path</td><td class="prmType"><code><a>DOMString</a></code></td><td class="prmNullFalse">?</td><td class="prmOptFalse">?</td><td class="prmDesc">
                Either an <a href="#dfn-absolute-path" class="internalDFN">absolute path</a> or a <a href="#dfn-relative-path" class="internalDFN">relative path</a> from
                this DirectoryEntrySync to the file to be looked up or created.
                It is an error to attempt to create a file whose immediate
                parent does not yet exist.
              </td></tr><tr><td class="prmName">options</td><td class="prmType"><code><a href="#idl-def-Flags" class="idlType"><code>Flags</code></a></code></td><td class="prmNullFalse">?</td><td class="prmOptTrue">?</td><td class="prmDesc">
                <ul>
                  <li>If <code>create</code> and <code>exclusive</code> are both
                  true and the path already exists, getFile <em class="rfc2119" title="must">must</em> fail.</li>
                  <li>If <code>create</code> is true, the path doesn't exist,
                  and no other error occurs, getFile <em class="rfc2119" title="must">must</em> create it as a
                  zero-length file and return a corresponding FileEntry.</li>
                  <li>If <code>create</code> is not true and the path doesn't
                  exist, getFile <em class="rfc2119" title="must">must</em> fail.</li>
                  <li>If <code>create</code> is not true and the path exists,
                  but is a directory, getFile <em class="rfc2119" title="must">must</em> fail.</li>
                  <li>Otherwise, if no other error occurs, getFile <em class="rfc2119" title="must">must</em>
                  return a FileEntrySync corresponding to path.</li>
                </ul>
              </td></tr></table><table class="exceptions"><tr><th>Exception</th><th>Description</th></tr><tr><td class="excName"><a href="#idl-def-FileException" class="idlType"><code>FileException</code></a></td><td class="excDesc"><table class="exceptionCodes"><tr><td class="excCodeName"><code>ENCODING_ERR</code></td><td class="excCodeDesc">The path was invalid.</td></tr><tr><td class="excCodeName"><code>NOT_FOUND_ERR</code></td><td class="excCodeDesc">The path was structurally correct, but refers to a resource
              that does not exist.</td></tr><tr><td class="excCodeName"><code>NO_MODIFICATION_ALLOWED_ERR</code></td><td class="excCodeDesc">The target directory or file is not writable.</td></tr><tr><td class="excCodeName"><code>PATH_EXISTS_ERR</code></td><td class="excCodeDesc">The user attempted to create a file where an element already
              exists.
              </td></tr><tr><td class="excCodeName"><code>QUOTA_EXCEEDED_ERR</code></td><td class="excCodeDesc">The operation would cause the application to exceed its
              storage quota.</td></tr><tr><td class="excCodeName"><code>SECURITY_ERR</code></td><td class="excCodeDesc">The application does not have permission to access the
              element referred to by path.</td></tr><tr><td class="excCodeName"><code>TYPE_MISMATCH_ERR</code></td><td class="excCodeDesc">The path supplied exists, but is not a directory.</td></tr></table></td></tr></table><div><em>Return type: </em><code><a href="#idl-def-FileEntrySync" class="idlType"><code>FileEntrySync</code></a></code></div></dd><dt id="widl-DirectoryEntrySync-removeRecursively"><code>removeRecursively</code></dt><dd>
            <p>
              Deletes a directory and all of its contents, if any.  In the event
              of an error [e.g. trying to delete a directory that contains a
              file that cannot be removed], some of the contents of the
              directory <em class="rfc2119" title="may">may</em> be deleted.  It is an error to attempt to delete the
              root directory of a filesystem.
            </p>
            
          <div><em>No parameters.</em></div><table class="exceptions"><tr><th>Exception</th><th>Description</th></tr><tr><td class="excName"><a href="#idl-def-FileException" class="idlType"><code>FileException</code></a></td><td class="excDesc"><table class="exceptionCodes"><tr><td class="excCodeName"><code>NOT_FOUND_ERR</code></td><td class="excCodeDesc">This DirectoryEntrySync refers to a resource that does not
              exist.</td></tr><tr><td class="excCodeName"><code>INVALID_STATE_ERR</code></td><td class="excCodeDesc">This DirectoryEntrySync is no longer valid for some reason
              other than it having been deleted.</td></tr><tr><td class="excCodeName"><code>NO_MODIFICATION_ALLOWED_ERR</code></td><td class="excCodeDesc">At least one of the target directory, its parent, or some of
              its contents, is not writable.</td></tr><tr><td class="excCodeName"><code>SECURITY_ERR</code></td><td class="excCodeDesc">The application does not have permission to access the target
              directory, its parent, or some of its contents.</td></tr></table></td></tr></table><div><em>Return type: </em><code><a>void</a></code></div></dd></dl></div>
      </div>
      
      <div id="the-directoryreadersync-interface" class="section">
        <h3><span class="secno">6.4 </span>The <code>DirectoryReaderSync</code> interface</h3>
        <p>
          This interface lets a user list files and directories in a directory.
          If there are no additions to or deletions from a directory between the
          first and last call to readEntries, and no errors occur, then:
          </p><ul>
            <li>A series of calls to readEntries <em class="rfc2119" title="must">must</em> return each entry in the
            directory exactly once.</li>
            <li>Once all entries have been returned, the next call to
            readEntries <em class="rfc2119" title="must">must</em> produce an empty array.</li>
            <li>If not all entries have been returned, the array produced by
            readEntries <em class="rfc2119" title="must not">must not</em> be empty.</li>
            <li>The entries produced by readEntries <em class="rfc2119" title="must not">must not</em> include the
            directory itself ["."] or its parent [".."].</li>
          </ul>
        <p></p>
        <pre class="idl"><span class="idlInterface" id="idl-def-DirectoryReaderSync">[<span class="extAttr">NoInterfaceObject</span>]
interface <span class="idlInterfaceID">DirectoryReaderSync</span> {
<span class="idlMethod">    <span class="idlMethType"><a href="#idl-def-EntrySync" class="idlType"><code>EntrySync</code></a>[]</span> <span class="idlMethName"><a href="#widl-DirectoryReaderSync-readEntries">readEntries</a></span> () raises (<span class="idlRaises"><a href="#idl-def-FileException" class="idlType"><code>FileException</code></a></span>);</span>
};</span>
</pre><div id="methods-16" class="section"><h4><span class="secno">6.4.1 </span>Methods</h4><dl class="methods"><dt id="widl-DirectoryReaderSync-readEntries"><code>readEntries</code></dt><dd>
            <p>
              Read the next block of entries from this directory.
            </p>
            
          <div><em>No parameters.</em></div><table class="exceptions"><tr><th>Exception</th><th>Description</th></tr><tr><td class="excName"><a href="#idl-def-FileException" class="idlType"><code>FileException</code></a></td><td class="excDesc"><table class="exceptionCodes"><tr><td class="excCodeName"><code>NOT_FOUND_ERR</code></td><td class="excCodeDesc">The directory no longer exists.</td></tr><tr><td class="excCodeName"><code>INVALID_STATE_ERR</code></td><td class="excCodeDesc">The directory has been modified since the first call to
              readEntries began to be processed.</td></tr><tr><td class="excCodeName"><code>SECURITY_ERR</code></td><td class="excCodeDesc">The <a href="#dfn-user-agent" class="internalDFN">user agent</a> determined that it was not safe to carry
              out this action.</td></tr></table></td></tr></table><div><em>Return type: </em><code><a href="#idl-def-EntrySync" class="idlType"><code>EntrySync</code></a>[]</code></div></dd></dl></div>
      </div>

      <div id="the-fileentrysync-interface" class="section">
        <h3><span class="secno">6.5 </span>The <code>FileEntrySync</code> interface</h3>
        <p>
          This interface represents a file on a file system.
        </p>
        <pre class="idl"><span class="idlInterface" id="idl-def-FileEntrySync">[<span class="extAttr">NoInterfaceObject</span>]
interface <span class="idlInterfaceID">FileEntrySync</span> : <span class="idlSuperclass"><a href="#idl-def-EntrySync" class="idlType"><code>EntrySync</code></a></span> {
<span class="idlMethod">    <span class="idlMethType"><a>FileWriterSync</a></span> <span class="idlMethName"><a href="#widl-FileEntrySync-createWriter">createWriter</a></span> () raises (<span class="idlRaises"><a href="#idl-def-FileException" class="idlType"><code>FileException</code></a></span>);</span>
<span class="idlMethod">    <span class="idlMethType"><a>File</a></span>           <span class="idlMethName"><a href="#widl-FileEntrySync-file">file</a></span> () raises (<span class="idlRaises"><a href="#idl-def-FileException" class="idlType"><code>FileException</code></a></span>);</span>
};</span>
</pre><div id="methods-17" class="section"><h4><span class="secno">6.5.1 </span>Methods</h4><dl class="methods"><dt id="widl-FileEntrySync-createWriter"><code>createWriter</code></dt><dd>
            <p>
            Creates a new <code>FileWriterSync</code> associated with the file
            that this <code>FileEntrySync</code> represents.
            </p>
            
          <div><em>No parameters.</em></div><table class="exceptions"><tr><th>Exception</th><th>Description</th></tr><tr><td class="excName"><a href="#idl-def-FileException" class="idlType"><code>FileException</code></a></td><td class="excDesc"><table class="exceptionCodes"><tr><td class="excCodeName"><code>NOT_FOUND_ERR</code></td><td class="excCodeDesc">The entry no longer exists.</td></tr><tr><td class="excCodeName"><code>INVALID_STATE_ERR</code></td><td class="excCodeDesc">This FileEntrySync is no longer valid for some reason other
              than it having been deleted.</td></tr><tr><td class="excCodeName"><code>SECURITY_ERR</code></td><td class="excCodeDesc">The <a href="#dfn-user-agent" class="internalDFN">user agent</a> determined that it was not safe to carry
              out this action.</td></tr></table></td></tr></table><div><em>Return type: </em><code><a>FileWriterSync</a></code></div></dd><dt id="widl-FileEntrySync-file"><code>file</code></dt><dd>
            <p>
              Returns a <code>File</code> that represents the current state of
              the file that this <code>FileEntrySync</code> represents.
            </p>
            
          <div><em>No parameters.</em></div><table class="exceptions"><tr><th>Exception</th><th>Description</th></tr><tr><td class="excName"><a href="#idl-def-FileException" class="idlType"><code>FileException</code></a></td><td class="excDesc"><table class="exceptionCodes"><tr><td class="excCodeName"><code>NOT_FOUND_ERR</code></td><td class="excCodeDesc">The entry no longer exists.</td></tr><tr><td class="excCodeName"><code>INVALID_STATE_ERR</code></td><td class="excCodeDesc">This FileEntrySync is no longer valid for some reason other
              than it having been deleted.</td></tr><tr><td class="excCodeName"><code>SECURITY_ERR</code></td><td class="excCodeDesc">The <a href="#dfn-user-agent" class="internalDFN">user agent</a> determined that it was not safe to carry
              out this action.</td></tr></table></td></tr></table><div><em>Return type: </em><code><a>File</a></code></div></dd></dl></div>
      </div>
    </div>
    
    <div id="dealing-with-errors-and-exceptions" class="section">
      <!--OddPage--><h2><span class="secno">7. </span>Dealing with errors and exceptions</h2>
      <div id="the-fileerror-interface" class="section">
        <h3><span class="secno">7.1 </span>The <code>FileError</code> interface</h3>
          <p>
            This interface extends the <a href="#idl-def-FileError" class="idlType"><code>FileError</code></a> interface described in
            [<cite><a class="bibref" rel="biblioentry" href="#bib-FILE-WRITER">FILE-WRITER</a></cite>] to add several new error codes.
            It is used to report errors asynchronously.
          </p>
          <pre class="idl"><span class="idlInterface" id="idl-def-FileError">interface <span class="idlInterfaceID">FileError</span> {
<span class="idlConst">    const <span class="idlConstType"><a>unsigned short</a></span> <span class="idlConstName"><a href="#widl-FileError-NOT_FOUND_ERR">NOT_FOUND_ERR</a></span> = <span class="idlConstValue">1</span>;</span>
<span class="idlConst">    const <span class="idlConstType"><a>unsigned short</a></span> <span class="idlConstName"><a href="#widl-FileError-SECURITY_ERR">SECURITY_ERR</a></span> = <span class="idlConstValue">2</span>;</span>
<span class="idlConst">    const <span class="idlConstType"><a>unsigned short</a></span> <span class="idlConstName"><a href="#widl-FileError-ABORT_ERR">ABORT_ERR</a></span> = <span class="idlConstValue">3</span>;</span>
<span class="idlConst">    const <span class="idlConstType"><a>unsigned short</a></span> <span class="idlConstName"><a href="#widl-FileError-NOT_READABLE_ERR">NOT_READABLE_ERR</a></span> = <span class="idlConstValue">4</span>;</span>
<span class="idlConst">    const <span class="idlConstType"><a>unsigned short</a></span> <span class="idlConstName"><a href="#widl-FileError-ENCODING_ERR">ENCODING_ERR</a></span> = <span class="idlConstValue">5</span>;</span>
<span class="idlConst">    const <span class="idlConstType"><a>unsigned short</a></span> <span class="idlConstName"><a href="#widl-FileError-NO_MODIFICATION_ALLOWED_ERR">NO_MODIFICATION_ALLOWED_ERR</a></span> = <span class="idlConstValue">6</span>;</span>
<span class="idlConst">    const <span class="idlConstType"><a>unsigned short</a></span> <span class="idlConstName"><a href="#widl-FileError-INVALID_STATE_ERR">INVALID_STATE_ERR</a></span> = <span class="idlConstValue">7</span>;</span>
<span class="idlConst">    const <span class="idlConstType"><a>unsigned short</a></span> <span class="idlConstName"><a href="#widl-FileError-SYNTAX_ERR">SYNTAX_ERR</a></span> = <span class="idlConstValue">8</span>;</span>
<span class="idlConst">    const <span class="idlConstType"><a>unsigned short</a></span> <span class="idlConstName"><a href="#widl-FileError-INVALID_MODIFICATION_ERR">INVALID_MODIFICATION_ERR</a></span> = <span class="idlConstValue">9</span>;</span>
<span class="idlConst">    const <span class="idlConstType"><a>unsigned short</a></span> <span class="idlConstName"><a href="#widl-FileError-QUOTA_EXCEEDED_ERR">QUOTA_EXCEEDED_ERR</a></span> = <span class="idlConstValue">10</span>;</span>
<span class="idlConst">    const <span class="idlConstType"><a>unsigned short</a></span> <span class="idlConstName"><a href="#widl-FileError-TYPE_MISMATCH_ERR">TYPE_MISMATCH_ERR</a></span> = <span class="idlConstValue">11</span>;</span>
<span class="idlConst">    const <span class="idlConstType"><a>unsigned short</a></span> <span class="idlConstName"><a href="#widl-FileError-PATH_EXISTS_ERR">PATH_EXISTS_ERR</a></span> = <span class="idlConstValue">12</span>;</span>
<span class="idlAttribute">    attribute <span class="idlAttrType"><a>unsigned short</a></span> <span class="idlAttrName"><a href="#widl-FileError-code">code</a></span>;</span>
};</span>
</pre><div id="attributes-6" class="section"><h4><span class="secno">7.1.1 </span>Attributes</h4><dl class="attributes"><dt id="widl-FileError-code"><code>code</code> of type <span class="idlAttrType"><a>unsigned short</a></span></dt><dd>
              The <a>code</a> attribute, on getting, <em class="rfc2119" title="must">must</em> return one of the
              constants of the <a href="#idl-def-FileError" class="idlType"><code>FileError</code></a> error, which <em class="rfc2119" title="must">must</em> be the most
              appropriate code from the table below.
            <div><em>No exceptions.</em></div></dd></dl></div><div id="constants-2" class="section"><h4><span class="secno">7.1.2 </span>Constants</h4><dl class="constants"><dt id="widl-FileError-ABORT_ERR"><code>ABORT_ERR</code> of type <span class="idlConstType"><a>unsigned short</a></span></dt><dd> </dd><dt id="widl-FileError-ENCODING_ERR"><code>ENCODING_ERR</code> of type <span class="idlConstType"><a>unsigned short</a></span></dt><dd> </dd><dt id="widl-FileError-INVALID_MODIFICATION_ERR"><code>INVALID_MODIFICATION_ERR</code> of type <span class="idlConstType"><a>unsigned short</a></span></dt><dd> </dd><dt id="widl-FileError-INVALID_STATE_ERR"><code>INVALID_STATE_ERR</code> of type <span class="idlConstType"><a>unsigned short</a></span></dt><dd> </dd><dt id="widl-FileError-NOT_FOUND_ERR"><code>NOT_FOUND_ERR</code> of type <span class="idlConstType"><a>unsigned short</a></span></dt><dd> </dd><dt id="widl-FileError-NOT_READABLE_ERR"><code>NOT_READABLE_ERR</code> of type <span class="idlConstType"><a>unsigned short</a></span></dt><dd> </dd><dt id="widl-FileError-NO_MODIFICATION_ALLOWED_ERR"><code>NO_MODIFICATION_ALLOWED_ERR</code> of type <span class="idlConstType"><a>unsigned short</a></span></dt><dd> </dd><dt id="widl-FileError-PATH_EXISTS_ERR"><code>PATH_EXISTS_ERR</code> of type <span class="idlConstType"><a>unsigned short</a></span></dt><dd> </dd><dt id="widl-FileError-QUOTA_EXCEEDED_ERR"><code>QUOTA_EXCEEDED_ERR</code> of type <span class="idlConstType"><a>unsigned short</a></span></dt><dd> </dd><dt id="widl-FileError-SECURITY_ERR"><code>SECURITY_ERR</code> of type <span class="idlConstType"><a>unsigned short</a></span></dt><dd> </dd><dt id="widl-FileError-SYNTAX_ERR"><code>SYNTAX_ERR</code> of type <span class="idlConstType"><a>unsigned short</a></span></dt><dd> </dd><dt id="widl-FileError-TYPE_MISMATCH_ERR"><code>TYPE_MISMATCH_ERR</code> of type <span class="idlConstType"><a>unsigned short</a></span></dt><dd> </dd></dl></div>
        
      </div>

      <div id="the-fileexception-exception" class="section">
        <h3><span class="secno">7.2 </span>The FileException exception</h3>
          This interface extends the <a href="#idl-def-FileException" class="idlType"><code>FileException</code></a> interface described in
          [<cite><a class="bibref" rel="biblioentry" href="#bib-FILE-WRITER">FILE-WRITER</a></cite>] to add several new error codes.  Any errors that need
          to be reported synchronously, including all that occur during use of
          the synchronous filesystem methods, are reported using the
          FileException exception.
        <pre class="idl"><span class="idlException" id="idl-def-FileException">exception <span class="idlExceptionID">FileException</span> {
<span class="idlConst">    const <span class="idlConstType"><a>unsigned short</a></span> <span class="idlConstName"><a href="#widl-FileException-NOT_FOUND_ERR">NOT_FOUND_ERR</a></span> = <span class="idlConstValue">1</span>;</span>
<span class="idlConst">    const <span class="idlConstType"><a>unsigned short</a></span> <span class="idlConstName"><a href="#widl-FileException-SECURITY_ERR">SECURITY_ERR</a></span> = <span class="idlConstValue">2</span>;</span>
<span class="idlConst">    const <span class="idlConstType"><a>unsigned short</a></span> <span class="idlConstName"><a href="#widl-FileException-ABORT_ERR">ABORT_ERR</a></span> = <span class="idlConstValue">3</span>;</span>
<span class="idlConst">    const <span class="idlConstType"><a>unsigned short</a></span> <span class="idlConstName"><a href="#widl-FileException-NOT_READABLE_ERR">NOT_READABLE_ERR</a></span> = <span class="idlConstValue">4</span>;</span>
<span class="idlConst">    const <span class="idlConstType"><a>unsigned short</a></span> <span class="idlConstName"><a href="#widl-FileException-ENCODING_ERR">ENCODING_ERR</a></span> = <span class="idlConstValue">5</span>;</span>
<span class="idlConst">    const <span class="idlConstType"><a>unsigned short</a></span> <span class="idlConstName"><a href="#widl-FileException-NO_MODIFICATION_ALLOWED_ERR">NO_MODIFICATION_ALLOWED_ERR</a></span> = <span class="idlConstValue">6</span>;</span>
<span class="idlConst">    const <span class="idlConstType"><a>unsigned short</a></span> <span class="idlConstName"><a href="#widl-FileException-INVALID_STATE_ERR">INVALID_STATE_ERR</a></span> = <span class="idlConstValue">7</span>;</span>
<span class="idlConst">    const <span class="idlConstType"><a>unsigned short</a></span> <span class="idlConstName"><a href="#widl-FileException-SYNTAX_ERR">SYNTAX_ERR</a></span> = <span class="idlConstValue">8</span>;</span>
<span class="idlConst">    const <span class="idlConstType"><a>unsigned short</a></span> <span class="idlConstName"><a href="#widl-FileException-INVALID_MODIFICATION_ERR">INVALID_MODIFICATION_ERR</a></span> = <span class="idlConstValue">9</span>;</span>
<span class="idlConst">    const <span class="idlConstType"><a>unsigned short</a></span> <span class="idlConstName"><a href="#widl-FileException-QUOTA_EXCEEDED_ERR">QUOTA_EXCEEDED_ERR</a></span> = <span class="idlConstValue">10</span>;</span>
<span class="idlConst">    const <span class="idlConstType"><a>unsigned short</a></span> <span class="idlConstName"><a href="#widl-FileException-TYPE_MISMATCH_ERR">TYPE_MISMATCH_ERR</a></span> = <span class="idlConstValue">11</span>;</span>
<span class="idlConst">    const <span class="idlConstType"><a>unsigned short</a></span> <span class="idlConstName"><a href="#widl-FileException-PATH_EXISTS_ERR">PATH_EXISTS_ERR</a></span> = <span class="idlConstValue">12</span>;</span>
<span class="idlField">    <span class="idlFieldType"><a>readonly attribute unsigned short</a></span> <span class="idlFieldName"><a href="#widl-FileException-code">code</a></span>;</span>
};</span>
</pre><div id="fields" class="section"><h4><span class="secno">7.2.1 </span>Fields</h4><dl class="fields"><dt id="widl-FileException-code"><code>code</code> of type <span class="idlFieldType"><a>readonly attribute unsigned short</a></span></dt><dd>
            The <a>code</a> attribute, on getting, <em class="rfc2119" title="must">must</em> return one of the
            constants of the <a href="#idl-def-FileException" class="idlType"><code>FileException</code></a> exception, which <em class="rfc2119" title="must">must</em> be the
            most appropriate code from the table below.
          </dd></dl></div><div id="constants-3" class="section"><h4><span class="secno">7.2.2 </span>Constants</h4><dl class="constants"><dt id="widl-FileException-ABORT_ERR"><code>ABORT_ERR</code> of type <span class="idlConstType"><a>unsigned short</a></span></dt><dd> </dd><dt id="widl-FileException-ENCODING_ERR"><code>ENCODING_ERR</code> of type <span class="idlConstType"><a>unsigned short</a></span></dt><dd> </dd><dt id="widl-FileException-INVALID_MODIFICATION_ERR"><code>INVALID_MODIFICATION_ERR</code> of type <span class="idlConstType"><a>unsigned short</a></span></dt><dd> </dd><dt id="widl-FileException-INVALID_STATE_ERR"><code>INVALID_STATE_ERR</code> of type <span class="idlConstType"><a>unsigned short</a></span></dt><dd> </dd><dt id="widl-FileException-NOT_FOUND_ERR"><code>NOT_FOUND_ERR</code> of type <span class="idlConstType"><a>unsigned short</a></span></dt><dd> </dd><dt id="widl-FileException-NOT_READABLE_ERR"><code>NOT_READABLE_ERR</code> of type <span class="idlConstType"><a>unsigned short</a></span></dt><dd> </dd><dt id="widl-FileException-NO_MODIFICATION_ALLOWED_ERR"><code>NO_MODIFICATION_ALLOWED_ERR</code> of type <span class="idlConstType"><a>unsigned short</a></span></dt><dd> </dd><dt id="widl-FileException-PATH_EXISTS_ERR"><code>PATH_EXISTS_ERR</code> of type <span class="idlConstType"><a>unsigned short</a></span></dt><dd> </dd><dt id="widl-FileException-QUOTA_EXCEEDED_ERR"><code>QUOTA_EXCEEDED_ERR</code> of type <span class="idlConstType"><a>unsigned short</a></span></dt><dd> </dd><dt id="widl-FileException-SECURITY_ERR"><code>SECURITY_ERR</code> of type <span class="idlConstType"><a>unsigned short</a></span></dt><dd> </dd><dt id="widl-FileException-SYNTAX_ERR"><code>SYNTAX_ERR</code> of type <span class="idlConstType"><a>unsigned short</a></span></dt><dd> </dd><dt id="widl-FileException-TYPE_MISMATCH_ERR"><code>TYPE_MISMATCH_ERR</code> of type <span class="idlConstType"><a>unsigned short</a></span></dt><dd> </dd></dl></div>
      </div>

      <div id="error-code-descriptions" class="section">
        <h3><span class="secno">7.3 </span>Error Code Descriptions</h3>
          <table class="simple"> 
            <thead> 
              <tr><th>Name</th><th>Value</th><th>Description</th></tr> 
            </thead> 
            <tbody> 
              
                <tr><td>ABORT_ERR</td><td>3</td>
                <td>
                  This value <em class="rfc2119" title="must not">must not</em> be used in this API.
                </td>
              </tr>
              <tr>
                <td>ENCODING_ERR</td><td>5</td>
                <td>
                  <a href="#dfn-user-agent" class="internalDFN">user agent</a> <em class="rfc2119" title="must">must</em> use this code when a URL supplied to
                  the API is malformed.
                </td>
              </tr>
              <tr>
                <td>INVALID_MODIFICATION_ERR</td><td>9</td>
                <td>
                  <a href="#dfn-user-agent" class="internalDFN">user agent</a> <em class="rfc2119" title="may">may</em> use this code if the modification
                  requested is illegal.  Examples of invalid modifications
                  include moving a directory into its own child or moving a file
                  into its parent directory without changing its name.
                </td>
              </tr>
              <tr>
                <td>INVALID_STATE_ERR</td><td>7</td>
                <td>
                  <a href="#dfn-user-agent" class="internalDFN">user agent</a> <em class="rfc2119" title="may">may</em> use this code if an operation depends on
                  state cached in an interface object that has changed since it
                  was read from disk.
                  <div class="issue">
                    Which values will actually go stale?  Modification
                    time, name, more rarely type.  If an atomic save [replacing
                    a file with a new one of the same name] happens underneath,
                    should we even be required to notice?
                  </div>
                </td>
              </tr>
              <tr>
                <td>NOT_FOUND_ERR</td><td>1</td>
                <td>
                  <a href="#dfn-user-agent" class="internalDFN">user agent</a> <em class="rfc2119" title="must">must</em> use this code if a required file or
                  directory could not be found at the time an operation was
                  processed.
                </td>
              </tr>
              <tr>
                <td>NOT_READABLE_ERR</td><td>4</td>
                <td>
                  <a href="#dfn-user-agent" class="internalDFN">user agent</a> <em class="rfc2119" title="must">must</em> use this code if a file or directory
                  cannot be read, typically due due to permission problems that
                  occur after a reference to a file has been acquired (e.g.
                  concurrent lock with another application).
                </td>
              </tr>
              <tr> 
                <td>NO_MODIFICATION_ALLOWED_ERR</td><td>6</td>
                <td><a href="#dfn-user-agent" class="internalDFN">user agent</a> <em class="rfc2119" title="must">must</em> use this code when attempting to
                  write to a file or directory which cannot be modified due to
                  the state of the underlying filesystem.
                </td>
              </tr>
              <tr> 
                <td>PATH_EXISTS_ERR</td><td>12</td>
                <td><a href="#dfn-user-agent" class="internalDFN">user agent</a> <em class="rfc2119" title="must">must</em> use this code when failing to
                  create a file or directory due to the existence of a file or
                  directory with the same path.
                </td>
              </tr>
              <tr>
                <td>QUOTA_EXCEEDED_ERR</td><td>10</td>
                <td>
                  <a href="#dfn-user-agent" class="internalDFN">user agent</a> <em class="rfc2119" title="must">must</em> use this code if the operation failed
                  because it would cause the application to exceed its storage
                  quota.
                </td>
              </tr>
              <tr>
                <td>SECURITY_ERR</td><td>2</td>
                <td>
                  <a href="#dfn-user-agent" class="internalDFN">user agent</a> <em class="rfc2119" title="may">may</em> use this code if:
                  <ul>
                    <li> it is determined that certain files are unsafe for
                    access within a Web application</li>
                    <li>it is determined that too many calls are being made on
                    file resources</li>
                  </ul>
                  This is a security error code to be used in situations not
                  covered by any other error codes.
                </td>
              </tr>
              <tr>
                <td>SYNTAX_ERR</td><td>8</td>
                <td>
                  This error code is not used in this specification; it is
                  included here only for completeness, as it is used in
                  [<cite><a class="bibref" rel="biblioentry" href="#bib-FILE-WRITER">FILE-WRITER</a></cite>].
                </td>
              </tr>
              <tr>
                <td>TYPE_MISMATCH_ERR</td><td>11</td>
                <td>
                  <a href="#dfn-user-agent" class="internalDFN">user agent</a> <em class="rfc2119" title="must">must</em> use this code when the user has
                  attempted to look up a file or directory, but the Entry
                  found is of the wrong type [e.g. is a DirectoryEntry when the
                  user requested a FileEntry].
                </td>
              </tr>
            </tbody>
          </table>
      </div>
    </div>
    
    <div id="uniformity-of-interface" class="section">
      <!--OddPage--><h2><span class="secno">8. </span>Uniformity of interface</h2>
      <div class="informative section">
        <p>
        In order to make it easy for web app developers to write portable
        applications that work on all platforms, we enforce certain restrictions
        and make certain guarantees with respect to paths used in this API.
        </p><p><em>This section is non-normative.</em></p>
        <p>
        These restrictions are intended to prevent developers from accidentally
        requiring the creation of paths that can only be created on a subset of
        platforms.  They are not intended to prevent access to files created
        outside of this API.
        </p>
      </div>
      The implementation <em class="rfc2119" title="must">must</em> refuse to create any file or directory whose name
      or existence would violate these rules.  The implementation <em class="rfc2119" title="may">may</em> accept a
      noncompliant path where it is used to look up an Entry or EntrySync for an
      existing file or directory.  The implementation <em class="rfc2119" title="must not">must not</em> accept a
      noncompliant path where it designates the new name of a file or directory
      to be moved, copied, or created.
      <p></p>
      <div class="issue">
        <p>
          What about path and path segment lengths?  For portability we should
          probably clip segments at 255 bytes of UTF-8 in normalization form D,
          and clip paths at 4095 bytes, but users can't easily check the byte
          length of strings, or renormalize, so that makes for an annoying API.
          It's also hard to control the true length of a path, due to renames of
          parent directories, so we really just want to reject the
          obviously-too-long; they won't often really come up anyway.
        </p>
        <p>
          What about normalization?  Are two different normalizations of the
          same string equivalent as filenames?  We don't want to let any
          underlying platform behaviors leak through.  This could be solved for
          in-API paths by supplying a "filenames are equal" function and
          normalizing everything inside the API, but we'd have to do it in both
          directions, since paths created outside the API might not be
          normalized.
        </p>
      </div>
      <div id="case-sensitivity" class="section">
        <h3><span class="secno">8.1 </span>Case-sensitivity</h3>
        <p>
          Paths in this filesystem are case-insensitive and case-preserving,
          regardless of the rules of the underlying filesystem, if any.
        </p>
        <p>
          Case-insensitivity <em class="rfc2119" title="should">should</em> respect the locale of the user.
        </p>
        <div class="issue">
          We could choose the user or the author; I think the user's probably
          the better way to go.  There are still situations in which you can get
          into trouble, but matching the locale of the user's computer should
          avoid many of the most common conflicts.
        </div>
      </div>
      <div id="directories" class="section">
        <h3><span class="secno">8.2 </span>Directories</h3>
        <p>
        The directory separator is '/', regardless of the directory separator
        used by the underlying system, if any.
        </p>
        <p>
        The character '/', when it is the first character in a path, refers to
        the root directory.
        </p>
        <p>
        All absolute paths begin with '/'; no relative paths begin with '/'.
        </p>
        <p>
        A <dfn id="dfn-relative-path">relative path</dfn> describes how to get from a particular
        directory to a file or directory.  All methods that accept paths are on
        <a href="#idl-def-DirectoryEntry" class="idlType"><code>DirectoryEntry</code></a> or <a href="#idl-def-DirectoryEntrySync" class="idlType"><code>DirectoryEntrySync</code></a> objects; the paths,
        if relative, are interpreted as being relative to the directories
        represented by these objects.
        </p>
        <p>
        An <dfn id="dfn-absolute-path">absolute path</dfn> is a <a href="#dfn-relative-path" class="internalDFN">relative path</a> from the root
        directory, prepended with a '/'.
        </p>
        <p>
        '.', when used where it is legal to use a directory name, refers to the
        currently-referenced directory.  Thus 'foo/./bar' is equivalent to
        'foo/bar', and './foo' is equivalent to 'foo'.
        </p>
        <p>
        '..', when used where it is legal to use a directory name, refers to the
        parent of the currently-referenced directory.  Thus, 'foo/..' refers to
        the directory containing 'foo', and '../foo' refers to an element named
        'foo' in the parent of the directory on whose DirectoryEntry or
        DirectoryEntrySync the method receiving the path is being called.
        </p>
        <p>
        Directories <em class="rfc2119" title="must not">must not</em> be made to contain more than 5000 entries.
        </p>
      </div>
      <div id="naming-restrictions" class="section">
        <h3><span class="secno">8.3 </span>Naming restrictions</h3>
        <p>
          Files and directories <em class="rfc2119" title="must not">must not</em> be named any of the following, and <em class="rfc2119" title="must
          not">must
          not</em> begin with any of the following followed by a period.
          </p><ul>
            <li>CON</li>
            <li>PRN</li>
            <li>AUX</li>
            <li>NUL</li>
            <li>COM1</li>
            <li>COM2</li>
            <li>COM3</li>
            <li>COM4</li>
            <li>COM5</li>
            <li>COM6</li>
            <li>COM7</li>
            <li>COM8</li>
            <li>COM9</li>
            <li>LPT1</li>
            <li>LPT2</li>
            <li>LPT3</li>
            <li>LPT4</li>
            <li>LPT5</li>
            <li>LPT6</li>
            <li>LPT7</li>
            <li>LPT8</li>
            <li>LPT9</li>
          </ul>
          These restrictions hold regardless of case, i.e. "con", "PrN" are also
          illegal.
        <p></p>
        <p>File and directory names <em class="rfc2119" title="must not">must not</em> end in period or space.
        </p>
        <p>File and directory names <em class="rfc2119" title="must not">must not</em> contain any of the following
        characters:
          </p><ul>
            <li>/</li>
            <li>\</li>
            <li>&lt;</li>
            <li>&gt;</li>
            <li>:</li>
            <li>?</li>
            <li>*</li>
            <li>"</li>
            <li>|</li>
          </ul>
        <p></p>
        <p>File and directory names <em class="rfc2119" title="must not">must not</em> contain any character whose
        representation in UTF-8 is between 0 and 31, inclusive.
        </p>
      </div>
    </div>
    <div class="appendix section" id="acknowledgements">
      <!--OddPage--><h2><span class="secno">A. </span>Acknowledgements</h2>
      <p>
        Thanks to Arun Ranganathan for his File API, Opera for theirs, and Robin
        Berjon both for his work on various file APIs and for ReSpec.
      </p>
    </div>
  

<div id="references" class="appendix section"><!--OddPage--><h2><span class="secno">B. </span>References</h2><div id="normative-references" class="section"><h3><span class="secno">B.1 </span>Normative references</h3><dl class="bibliography"><dt id="bib-FILE-API">[FILE-API]</dt><dd>Arun Ranganathan. <a href="http://www.w3.org/TR/2009/WD-FileAPI-20091117/"><cite>File API.</cite></a> 17 November 2009. W3C Working Draft. (Work in progress.) URL: <a href="http://www.w3.org/TR/2009/WD-FileAPI-20091117/">http://www.w3.org/TR/2009/WD-FileAPI-20091117/</a> 
</dd><dt id="bib-FILE-WRITER">[FILE-WRITER]</dt><dd>Eric Uhrhane. <a href="http://dev.w3.org/2009/dap/file-system/file-writer.html"><cite>File Writer API.</cite></a> W3C Working Draft. (Work in progress.) URL: <a href="http://dev.w3.org/2009/dap/file-system/file-writer.html">http://dev.w3.org/2009/dap/file-system/file-writer.html</a> 
</dd><dt id="bib-RFC2119">[RFC2119]</dt><dd>S. Bradner. <a href="http://www.ietf.org/rfc/rfc2119.txt"><cite>Key words for use in RFCs to Indicate Requirement Levels.</cite></a> March 1997. Internet RFC 2119.  URL: <a href="http://www.ietf.org/rfc/rfc2119.txt">http://www.ietf.org/rfc/rfc2119.txt</a> 
</dd><dt id="bib-WEBWORKERS">[WEBWORKERS]</dt><dd>Ian Hickson. <a href="http://www.w3.org/TR/2009/WD-workers-20091222/"><cite>Web Workers.</cite></a> 22 December 2009. W3C Working Draft. (Work in progress.) URL: <a href="http://www.w3.org/TR/2009/WD-workers-20091222/">http://www.w3.org/TR/2009/WD-workers-20091222/</a> 
</dd></dl></div><div id="informative-references" class="section"><h3><span class="secno">B.2 </span>Informative references</h3><p>No informative references.</p></div></div></body></html>