diff --git a/filesystem/filesystem-tests.ts b/filesystem/filesystem-tests.ts
new file mode 100644
index 000000000..8f175db98
--- /dev/null
+++ b/filesystem/filesystem-tests.ts
@@ -0,0 +1,49 @@
+///
+// http://www.w3.org/TR/file-system-api/
+
+// 2. Introduction
+declare function getAsText(file:File): void;
+declare function writeDataToLogFile(fileWriter:FileWriterSync): void;
+
+function useAsyncFS(fs:FileSystem):void {
+ // see getAsText example in [FILE-API-ED].
+ fs.root.getFile("already_there.txt", null, function (f:FileEntry): void{
+
+ // In the example of the specification, there is a following code:
+ //
+ // getAsText(f.file());
+ //
+ // It seems wrong because f is ASYNCRONOUS file system.
+ f.file(getAsText);
+
+ });
+
+ // But now we can also write to the file; see [FILE-WRITER-ED].
+ fs.root.getFile("logFile", {create: true}, function (f:FileEntry): void{
+ f.createWriter(writeDataToLogFile);
+ });
+}
+window.requestFileSystem(window.TEMPORARY, 1024 * 1024, function(fs:FileSystem): void{
+ useAsyncFS(fs);
+});
+
+// In a worker:
+
+var tempFS:FileSystemSync = window.requestFileSystemSync(window.TEMPORARY, 1024 * 1024);
+var logFile:FileEntrySync = tempFS.root.getFile("logFile", {create: true});
+var writer:FileWriterSync = logFile.createWriter();
+writer.seek(writer.length);
+writeDataToLogFile(writer);
+
+
+// 5.2 The Flags dictionary
+var fsSync:FileSystemSync = window.requestFileSystemSync(window.TEMPORARY, 1024 * 1024);
+// Get the data directory, creating it if it doesn't exist.
+var dataDir:DirectoryEntrySync = fsSync.root.getDirectory("data", {create: true});
+
+// Create the lock file, if and only if it doesn't exist.
+try {
+ var lockFile:FileEntrySync = dataDir.getFile("lockfile.txt", {create: true, exclusive: true});
+} catch (ex) {
+ // It already exists, or something else went wrong.
+}
diff --git a/filesystem/filesystem.d.ts b/filesystem/filesystem.d.ts
index 69477b13d..444f67a47 100644
--- a/filesystem/filesystem.d.ts
+++ b/filesystem/filesystem.d.ts
@@ -1,6 +1,9 @@
// Type Definitions for File API: Directories and System (File System API)
-// Specification: http://www.w3.org/TR/file-system-api/
+// Project: http://www.w3.org/TR/file-system-api/
// Definitions by: Kon
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+///
interface LocalFileSystem {
@@ -8,7 +11,7 @@ interface LocalFileSystem {
* Used for storage with no guarantee of persistence.
*/
TEMPORARY:number;
-
+
/**
* Used for storage that should not be removed by the user agent without application or user permission.
*/
@@ -32,7 +35,7 @@ interface LocalFileSystem {
resolveLocalFileSystemURL(url:string, successCallback:EntryCallback, errorCallback?:ErrorCallback):void;
/**
- * see resolveLocalFileSystemURL.
+ * see requestFileSystem.
*/
webkitRequestFileSystem(type:number, size:number, successCallback:FileSystemCallback, errorCallback?:ErrorCallback):void;
}