void KURL::setPath(const String& path) { // Empty paths will be canonicalized to "/", so we don't have to worry // about calling ClearPath(). StringUTF8Adaptor pathUTF8(path); url::Replacements<char> replacements; replacements.SetPath(charactersOrEmpty(pathUTF8), url::Component(0, pathUTF8.length())); replaceComponents(replacements); }
int CSysStatClass::mkdir(Stringp path, int mode) { if (!path) { toplevel()->throwArgumentError(kNullArgumentError, "path"); } #if AVMSYSTEM_WIN32 StUTF16String pathUTF16(path); return VMPI_mkdir16( pathUTF16.c_str(), mode ); #else StUTF8String pathUTF8(path); return VMPI_mkdir( pathUTF8.c_str(), mode ); #endif }
/*static*/ int CSysStatClass::chmod(ScriptObject* self, Stringp path, int mode) { Toplevel* toplevel = self->toplevel(); if (!path) { toplevel->throwArgumentError(kNullArgumentError, "path"); } #if AVMSYSTEM_WIN32 StUTF16String pathUTF16(path); return VMPI_chmod16( pathUTF16.c_str(), mode ); #else StUTF8String pathUTF8(path); return VMPI_chmod( pathUTF8.c_str(), mode ); #endif }
/*static*/ int CSysStatClass::stat(ScriptObject* self, Stringp path, CStatusObject* buf) { Toplevel* toplevel = self->toplevel(); if (!path) { toplevel->throwArgumentError(kNullArgumentError, "path"); } if (!buf) { toplevel->throwArgumentError(kNullArgumentError, "buf"); } struct stat statbuf; #if AVMSYSTEM_WIN32 StUTF16String pathUTF16(path); int result = VMPI_stat16( pathUTF16.c_str(), &statbuf ); #else StUTF8String pathUTF8(path); int result = VMPI_stat( pathUTF8.c_str(), &statbuf ); #endif if( result != -1 ) { buf->set_st_dev( statbuf.st_dev ); buf->set_st_ino( statbuf.st_ino ); buf->set_st_mode( statbuf.st_mode ); buf->set_st_nlink( statbuf.st_nlink ); buf->set_st_uid( statbuf.st_uid ); buf->set_st_gid( statbuf.st_gid ); buf->set_st_rdev( statbuf.st_rdev ); buf->set_st_size( (double) statbuf.st_size ); buf->set_st_atime( (double) statbuf.st_atime ); buf->set_st_mtime( (double) statbuf.st_mtime ); buf->set_st_ctime( (double) statbuf.st_ctime ); } return result; }
/*static*/ Stringp CStdlibClass::realpath(ScriptObject* self, Stringp path) { AvmCore *core = self->core(); Toplevel* toplevel = self->toplevel(); if( !path ) { toplevel->throwArgumentError(kNullArgumentError, "path"); } #if AVMSYSTEM_WIN32 StUTF16String pathUTF16(path); wchar * str = VMPI_realpath16( pathUTF16.c_str() ); Stringp value = core->newStringUTF16( str ); StUTF8String valueUTF8(value); return core->newStringUTF8( valueUTF8.c_str() ); #else StUTF8String pathUTF8(path); char * str = VMPI_realpath( pathUTF8.c_str() ); return core->newStringUTF8( str ); #endif }