Subj : Re: about File.currentDir To : netscape.public.mozilla.jseng From : Taro Kato Date : Fri Mar 26 2004 06:28 pm Hi, /be Although your pache was tried, it did not operate correctly. currentDir is a class property. For this reason, obj is not a File object but a File constructor object (File class). Since JS_InstanceOf went wrong, directory movement was impossible. I corrected as follows. At last, File.currentDir can change by File path or File object. ---------------------------------------------- static JSBool file_currentDirSetter(JSContext *cx, JSObject *obj, jsval id, jsval *vp) { JSObject *rhsObject; char *path; JSFile *file; /* Look at the rhs and extract a file object from it */ if (!JSVAL_IS_PRIMITIVE(*vp)) { rhsObject = JSVAL_TO_OBJECT(*vp); file = JS_GetInstancePrivate(cx, rhsObject, &file_class, NULL); if (JS_InstanceOf(cx, rhsObject, &file_class, NULL)){ /* Braindamaged rhs -- just return the old value */ if (file && (!js_exists(cx, file) || !js_isDirectory(cx, file))){ JS_GetProperty(cx, obj, CURRENTDIR_PROPERTY, vp); }else{ rhsObject = JSVAL_TO_OBJECT(*vp); chdir(file->path); } }else goto out; } else{ path = JS_GetStringBytes(JS_ValueToString(cx, *vp)); rhsObject = js_NewFileObject(cx, path); if (!rhsObject) goto out; file = JS_GetInstancePrivate(cx, rhsObject, &file_class, NULL); if (!file || !js_exists(cx, file) || !js_isDirectory(cx, file)){ JS_GetProperty(cx, obj, CURRENTDIR_PROPERTY, vp); }else{ *vp = OBJECT_TO_JSVAL(rhsObject); chdir(file->path); } } return JS_TRUE; out: *vp = JSVAL_VOID; return JS_FALSE; } ---------------------------------------------- Kind regards. ----- Since I cannot write English, I am using the language translation machine. Sorry if Words of me is unsuitable. ----- Taro Kato @ Tokyo Japan .