summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'file.c')
-rw-r--r--file.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/file.c b/file.c
index 898c8009aa..decb5ba81e 100644
--- a/file.c
+++ b/file.c
@@ -71,6 +71,33 @@ char *strrchr _((const char*,const char));
# define fseeko fseek
#endif
+#ifdef __BEOS__ /* should not change ID if -1 */
+static int
+be_chown(const char *path, uid_t owner, gid_t group)
+{
+ if (owner == -1 || group == -1) {
+ struct stat st;
+ if (stat(path, &st) < 0) return -1;
+ if (owner == -1) owner = st.st_uid;
+ if (group == -1) group = st.st_gid;
+ }
+ return chown(path, owner, group);
+}
+#define chown be_chown
+static int
+be_fchown(int fd, uid_t owner, gid_t group)
+{
+ if (owner == -1 || group == -1) {
+ struct stat st;
+ if (fstat(fd, &st) < 0) return -1;
+ if (owner == -1) owner = st.st_uid;
+ if (group == -1) group = st.st_gid;
+ }
+ return fchown(fd, owner, group);
+}
+#define fchown be_fchown
+#endif /* __BEOS__ */
+
VALUE rb_cFile;
VALUE rb_mFileTest;
static VALUE rb_cStat;
@@ -1957,6 +1984,7 @@ static VALUE
rb_file_s_link(klass, from, to)
VALUE klass, from, to;
{
+#ifdef HAVE_LINK
SafeStringValue(from);
SafeStringValue(to);
@@ -1964,6 +1992,10 @@ rb_file_s_link(klass, from, to)
sys_fail2(from, to);
}
return INT2FIX(0);
+#else
+ rb_notimplement();
+ return Qnil; /* not reached */
+#endif
}
/*