Skip to content
Browse files

split low-level and high-level code in io.directories

  • Loading branch information...
1 parent bc0242b commit 777b172db89d1eb5852740d6bde3727e38427964 @stepancheg stepancheg committed Dec 7, 2012
View
10 lib-clay/io/directories/directories.clay
@@ -1,10 +1,9 @@
import data.vectors.(Vector);
import data.strings.(String);
+import data.strings.tempcstrings.(tempCString);
import io.directories.platform.*;
-public import io.directories.platform.(makeDirectory, deleteDirectory);
-
/// @section listDirectory
@@ -17,3 +16,10 @@ listDirectory(x) {
return r;
}
+makeDirectory(path) {
+ makeDirectoryImpl(tempCString(path).cstring);
+}
+
+deleteDirectory(path) {
+ deleteDirectoryImpl(tempCString(path).cstring);
+}
View
8 lib-clay/io/directories/platform/platform.unix.clay
@@ -55,16 +55,16 @@ overload nextValue(x:DirectoryIterator) {
/// @section makeDirectory, deleteDirectory
-makeDirectory(path) {
+makeDirectoryImpl(path: CStringRef) {
alias oct777 = 511;
- var r = mkdir(cstring(path), mode_t(oct777));
+ var r = mkdir(path.ptr, mode_t(oct777));
if (r < 0) {
throw GenericIOError(errno(), "mkdir");
}
}
-deleteDirectory(path) {
- var r = rmdir(cstring(path));
+deleteDirectoryImpl(path: CStringRef) {
+ var r = rmdir(path.ptr);
if (r < 0) {
throw GenericIOError(errno(), "rmdir");
}
View
8 lib-clay/io/directories/platform/platform.windows.clay
@@ -65,15 +65,15 @@ overload nextValue(it: DirectoryIterator) {
/// @section makeDirectory, deleteDirectory
-makeDirectory(path) {
- var ok = CreateDirectoryA(cstring(path), null(SECURITY_ATTRIBUTES));
+makeDirectoryImpl(path: CStringRef) {
+ var ok = CreateDirectoryA(path.ptr, null(SECURITY_ATTRIBUTES));
if (ok == 0) {
throw GenericIOError(GetLastError(), "CreateDirectoryA");
}
}
-deleteDirectory(path) {
- var ok = RemoveDirectoryA(cstring(path));
+deleteDirectoryImpl(path: CStringRef) {
+ var ok = RemoveDirectoryA(path.ptr);
if (ok == 0) {
throw GenericIOError(GetLastError(), "RemoveDirectoryA");
}

0 comments on commit 777b172

Please sign in to comment.
Something went wrong with that request. Please try again.