         }
         try data.withUnsafeBufferPointer {
             if fwrite($0.baseAddress, 1, data.count, self.pointer) != data.count {
-                throw FileError.WriteFailed(File.descriptionOfLastError())
+                throw FileError.WriteFailed(Errno.description())
             }
         }
     }
     
     public func seek(offset: Int) throws -> Void {
         if fseek(self.pointer, offset, SEEK_SET) != 0 {
-            throw FileError.SeekFailed(File.descriptionOfLastError())
+            throw FileError.SeekFailed(Errno.description())
         }
     }
-    
-    private static func descriptionOfLastError() -> String {
-        return String.fromCString(UnsafePointer(strerror(errno))) ?? "Error: \(errno)"
-    }
+
 }
 
-extension File {
-    
-    public static func withNewFileOpenedForWriting<Result>(path: String, _ f: File throws -> Result) throws -> Result {
-        return try withFileOpenedForMode(path, mode: "wb", f)
+public func withNewFileOpenedForWriting<Result>(path: String, _ f: File throws -> Result) throws -> Result {
+    return try withFileOpenedForMode(path, mode: "wb", f)
+}
+
+public func withFileOpenedForReading<Result>(path: String, _ f: File throws -> Result) throws -> Result {
+    return try withFileOpenedForMode(path, mode: "rb", f)
+}
+
+public func withFileOpenedForWritingAndReading<Result>(path: String, _ f: File throws -> Result) throws -> Result {
+    return try withFileOpenedForMode(path, mode: "r+b", f)
+}
+
+public func withFileOpenedForMode<Result>(path: String, mode: String, _ f: File throws -> Result) throws -> Result {
+    let file = try File.openFileForMode(path, mode)
+    defer {
+        file.close()
     }
-    
-    public static func withFileOpenedForReading<Result>(path: String, _ f: File throws -> Result) throws -> Result {
-        return try withFileOpenedForMode(path, mode: "rb", f)
-    }
-    
-    public static func withFileOpenedForWritingAndReading<Result>(path: String, _ f: File throws -> Result) throws -> Result {
-        return try withFileOpenedForMode(path, mode: "r+b", f)
-    }
-    
-    public static func withFileOpenedForMode<Result>(path: String, mode: String, _ f: File throws -> Result) throws -> Result {
-        let file = try File.openFileForMode(path, mode)
-        defer {
-            file.close()
-        }
-        return try f(file)
-    }
+    return try f(file)
 }
+

            return count
        }
        if ferror(self.pointer) != 0 {
            throw FileError.ReadFailed(File.descriptionOfLastError())
        }
        throw FileError.ReadFailed("Unknown file read error occured.")
    }

    public static func list(path: String) throws -> [String] {
        let dir = path.withCString { opendir($0) }
        if dir == nil {
            throw FileError.OpenDirFailed(Errno.description())
        }
        defer { closedir(dir) }
        var results = [String]()
