aboutsummaryrefslogtreecommitdiff
path: root/jim-win32.c
diff options
context:
space:
mode:
authorpatthoyts <patthoyts>2005-04-19 15:33:28 +0000
committerpatthoyts <patthoyts>2005-04-19 15:33:28 +0000
commit067a9fc5fb6510ddca567274e00c9392c850a82d (patch)
tree1a9edf331b27f080a3cbcebf7c50b35572717550 /jim-win32.c
parentc2852ab7ad42b320fb64ba07fc644c5593c15adb (diff)
downloadjimtcl-067a9fc5fb6510ddca567274e00c9392c850a82d.zip
jimtcl-067a9fc5fb6510ddca567274e00c9392c850a82d.tar.gz
jimtcl-067a9fc5fb6510ddca567274e00c9392c850a82d.tar.bz2
Added CreateDirectory and RemoveDirectory
Diffstat (limited to 'jim-win32.c')
-rw-r--r--jim-win32.c53
1 files changed, 52 insertions, 1 deletions
diff --git a/jim-win32.c b/jim-win32.c
index 35be393..93421bf 100644
--- a/jim-win32.c
+++ b/jim-win32.c
@@ -2,7 +2,7 @@
*
* Copyright (C) 2005 Pat Thoyts <patthoyts@users.sourceforge.net>
*
- * $Id: jim-win32.c,v 1.25 2005/04/13 19:57:22 patthoyts Exp $
+ * $Id: jim-win32.c,v 1.26 2005/04/19 15:33:28 patthoyts Exp $
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -748,6 +748,55 @@ Win32_FreeLibrary(Jim_Interp *interp, int objc, Jim_Obj *const *objv)
/* ----------------------------------------------------------------------
+ * Filesystem APIs
+ */
+
+static int
+Win32_CreateDirectory(Jim_Interp *interp, int objc, Jim_Obj *const *objv)
+{
+ const char * path;
+
+ if (objc != 2) {
+ Jim_WrongNumArgs(interp, 1, objv, "path");
+ return JIM_ERR;
+ }
+
+ path = Jim_GetString(objv[1], NULL);
+ if (!CreateDirectoryA(path, NULL)) {
+ Jim_SetResult(interp,
+ Win32ErrorObj(interp, "CreateDirectory", GetLastError()));
+ return JIM_ERR;
+ }
+
+ return JIM_OK;
+}
+
+static int
+Win32_RemoveDirectory(Jim_Interp *interp, int objc, Jim_Obj *const *objv)
+{
+ const char * path;
+
+ if (objc != 2) {
+ Jim_WrongNumArgs(interp, 1, objv, "path");
+ return JIM_ERR;
+ }
+
+ path = Jim_GetString(objv[1], NULL);
+ if (!RemoveDirectoryA(path)) {
+ Jim_SetResult(interp,
+ Win32ErrorObj(interp, "RemoveDirectory", GetLastError()));
+ return JIM_ERR;
+ }
+
+ return JIM_OK;
+}
+
+/*
+ * CopyFile, MoveFile, CreateFile, DeleteFile, LockFile,
+ * ReadFile and WriteFile should get rolled into a stream/channel thing.
+ */
+
+/* ----------------------------------------------------------------------
* Cleanup for dynamically loaded commands.
*/
@@ -799,6 +848,8 @@ Jim_OnLoad(Jim_Interp *interp)
CMD(GetModuleHandle);
CMD(LoadLibrary);
CMD(FreeLibrary);
+ CMD(CreateDirectory);
+ CMD(RemoveDirectory);
#if WINVER >= 0x0500
CMD(GetCursorInfo);