/* -*-C-*-
-$Id: ntfs.c,v 1.8 1995/10/24 04:56:58 cph Exp $
+$Id: ntfs.c,v 1.9 1995/10/28 01:03:40 cph Exp $
Copyright (c) 1992-95 Massachusetts Institute of Technology
return (0);
}
+static void
+DEFUN (guarantee_writable, (name, errorp),
+ CONST char * name AND
+ int errorp)
+{
+ DWORD attributes = (GetFileAttributes (name));
+ if (attributes == 0xFFFFFFFF)
+ {
+ DWORD error_code = (GetLastError ());
+ if ((error_code != ERROR_FILE_NOT_FOUND) && errorp)
+ error_system_call (error_code, syscall_stat);
+ }
+ else if ((attributes & FILE_ATTRIBUTE_READONLY) != 0)
+ {
+ if ((! (SetFileAttributes (name,
+ (attributes &~ FILE_ATTRIBUTE_READONLY))))
+ && errorp)
+ error_system_call ((GetLastError ()), syscall_chmod);
+ }
+}
+
void
DEFUN (OS_file_remove, (name), CONST char * name)
{
+ guarantee_writable (name, 1);
STD_VOID_SYSTEM_CALL (syscall_unlink, (NT_unlink (name)));
}
DEFUN (OS_file_remove_link, (name), CONST char * name)
{
struct stat s;
- if ( (NT_stat (name, (&s)) == 0) &&
- (((s . st_mode) & S_IFMT) == S_IFREG) )
- NT_unlink (name);
- return;
+ if ((NT_stat (name, (&s)) == 0)
+ && (((s . st_mode) & S_IFMT) == S_IFREG))
+ {
+ guarantee_writable (name, 0);
+ NT_unlink (name);
+ }
}
void
-DEFUN (OS_file_link_hard, (from_name, to_name),
- CONST char * from_name AND
- CONST char * to_name)
+DEFUN (OS_file_rename, (from, to),
+ CONST char * from AND
+ CONST char * to)
{
- error_unimplemented_primitive ();
+ guarantee_writable (name, 1);
+ STD_BOOL_SYSTEM_CALL (syscall_rename, (MoveFile (from, to)));
}
void
-DEFUN (OS_file_link_soft, (from_name, to_name),
+DEFUN (OS_file_copy, (from, to),
+ CONST char * from AND
+ CONST char * to)
+{
+ guarantee_writable (name, 1);
+ /* This system-call name is wrong, but there's no corresponding unix
+ operation, and I don't feel like customizing this for NT now. */
+ STD_BOOL_SYSTEM_CALL (syscall_rename, (CopyFile (from, to, FALSE)));
+}
+
+void
+DEFUN (OS_file_link_hard, (from_name, to_name),
CONST char * from_name AND
CONST char * to_name)
{
error_unimplemented_primitive ();
}
-\f
+
void
-DEFUN (OS_file_rename, (from_name, to_name),
+DEFUN (OS_file_link_soft, (from_name, to_name),
CONST char * from_name AND
CONST char * to_name)
{
- if ((NT_rename (from_name, to_name)) != 0)
- error_system_call (errno, syscall_rename);
+ error_unimplemented_primitive ();
}
void
/* -*-C-*-
-$Id: prntfs.c,v 1.4 1995/10/27 07:55:05 cph Exp $
+$Id: prntfs.c,v 1.5 1995/10/28 01:03:30 cph Exp $
Copyright (c) 1993-95 Massachusetts Institute of Technology
extern int EXFUN
(NT_read_file_status, (CONST char * filename, struct stat * s));
+extern void EXFUN (OS_file_copy, (CONST char *, CONST char *));
static SCHEME_OBJECT EXFUN (file_attributes_internal, (struct stat * s));
static void EXFUN (file_mode_string, (struct stat * s, char * a));
VECTOR_SET (result, 4, (char_pointer_to_string (file_system_name)));
PRIMITIVE_RETURN (result);
}
+
+DEFINE_PRIMITIVE ("NT-COPY-FILE", Prim_NT_copy_file, 2, 2, 0)
+{
+ PRIMITIVE_HEADER (2);
+ OS_file_copy ((STRING_ARG (1)), (STRING_ARG (2)));
+ PRIMITIVE_RETURN (UNSPECIFIC);
+}
+
+DEFINE_PRIMITIVE ("NT-GET-FILE-ATTRIBUTES", Prim_NT_get_file_attributes, 1, 1, 0)
+{
+ PRIMITIVE_HEADER (1);
+ {
+ CONST char * filename = (STRING_ARG (1));
+ DWORD attributes = (GetFileAttributes (filename));
+ if (attributes == 0xFFFFFFFF)
+ {
+ DWORD error_code = (GetLastError ());
+ if (error_code != ERROR_FILE_NOT_FOUND)
+ error_system_call (error_code, syscall_stat);
+ PRIMITIVE_RETURN (SHARP_F);
+ }
+ PRIMITIVE_RETURN (ulong_to_integer (attributes));
+ }
+}
+
+DEFINE_PRIMITIVE ("NT-SET-FILE-ATTRIBUTES", Prim_NT_set_file_attributes, 2, 2, 0)
+{
+ PRIMITIVE_HEADER (2);
+ STD_BOOL_SYSTEM_CALL
+ (syscall_chmod,
+ (SetFileAttributes ((STRING_ARG (1)), (arg_ulong_integer (2)))));
+ PRIMITIVE_RETURN (UNSPECIFIC);
+}