QStringList KFileItem::overlays() const { QStringList names = d->m_entry.stringValue( KIO::UDSEntry::UDS_ICON_OVERLAY_NAMES ).split(','); if ( d->m_bLink ) { names.append("emblem-symbolic-link"); } if ( !S_ISDIR( d->m_fileMode ) // Locked dirs have a special icon, use the overlay for files only && !isReadable()) { names.append("object-locked"); } if ( checkDesktopFile(*this, false) ) { KDesktopFile cfg( localPath() ); const KConfigGroup group = cfg.desktopGroup(); // Add a warning emblem if this is an executable desktop file // which is untrusted. if ( group.hasKey( "Exec" ) && !KDesktopFile::isAuthorizedDesktopFile( localPath() ) ) { names.append( "emblem-important" ); } if (cfg.hasDeviceType()) { const QString dev = cfg.readDevice(); if (!dev.isEmpty()) { KMountPoint::Ptr mountPoint = KMountPoint::currentMountPoints().findByDevice(dev); if (mountPoint) // mounted? names.append("emblem-mounted"); } } } if ( isHidden() ) { names.append("hidden"); } #ifndef Q_OS_WIN if( S_ISDIR( d->m_fileMode ) && d->m_bIsLocalUrl) { if (KSambaShare::instance()->isDirectoryShared( d->m_url.toLocalFile() ) || KNFSShare::instance()->isDirectoryShared( d->m_url.toLocalFile() )) { //kDebug() << d->m_url.path(); names.append("network-workgroup"); } } #endif // Q_OS_WIN if ( d->m_pMimeType && d->m_url.fileName().endsWith( QLatin1String( ".gz" ) ) && d->m_pMimeType->is("application/x-gzip") ) { names.append("application-zip"); } return names; }
QDateTime KFileItemPrivate::time(KFileItem::FileTimes mappedWhich) const { if (!m_time[mappedWhich].isNull()) { return m_time[mappedWhich]; } // Extract it from the KIO::UDSEntry long long fieldVal = -1; switch (mappedWhich) { case KFileItem::ModificationTime: fieldVal = m_entry.numberValue(KIO::UDSEntry::UDS_MODIFICATION_TIME, -1); break; case KFileItem::AccessTime: fieldVal = m_entry.numberValue(KIO::UDSEntry::UDS_ACCESS_TIME, -1); break; case KFileItem::CreationTime: fieldVal = m_entry.numberValue(KIO::UDSEntry::UDS_CREATION_TIME, -1); break; } if (fieldVal != -1) { setTime(mappedWhich, QDateTime::fromMSecsSinceEpoch(1000 * fieldVal)); return m_time[mappedWhich]; } // If not in the KIO::UDSEntry, or if UDSEntry empty, use stat() [if local URL] if (m_bIsLocalUrl) { QFileInfo info(localPath()); setTime(KFileItem::ModificationTime, info.lastModified()); setTime(KFileItem::AccessTime, info.lastRead()); setTime(KFileItem::CreationTime, info.created()); return m_time[mappedWhich]; } return QDateTime(); }
JNIEXPORT void JNICALL Java_org_apache_subversion_javahl_SVNClient_mergeReintegrate (JNIEnv *env, jobject jthis, jstring jpath, jobject jpegRevision, jstring jlocalPath, jboolean jdryRun) { JNIEntry(SVNClient, mergeReintegrate); SVNClient *cl = SVNClient::getCppObject(jthis); if (cl == NULL) { JNIUtil::throwError(_("bad C++ this")); return; } JNIStringHolder path(jpath); if (JNIUtil::isExceptionThrown()) return; Revision pegRevision(jpegRevision); if (JNIUtil::isExceptionThrown()) return; JNIStringHolder localPath(jlocalPath); if (JNIUtil::isExceptionThrown()) return; cl->mergeReintegrate(path, pegRevision, localPath, jdryRun ? true:false); }
std::string VisualizationNode::toXML(const std::string &basePath, const std::string &filename, int tabs) { std::stringstream ss; std::string t = "\t"; std::string pre = ""; for (int i=0;i<tabs;i++) pre += "\t"; ss << pre << "<Visualization"; if (usedBoundingBoxVisu()) { ss << " BoundingBox='true'"; } ss << ">\n"; if (!filename.empty()) { boost::filesystem::path localPath(basePath); boost::filesystem::path fn(filename); boost::filesystem::path completeFile = boost::filesystem::operator/(localPath,fn); ss << pre << t << "<File type='" << getType() << "'>" << completeFile.string() << "</File>\n"; } ss << pre << "</Visualization>\n"; return ss.str(); }
void CState::UploadDroppedFiles(const wxFileDataObject* pFileDataObject, const CServerPath& path, bool queueOnly) { if (!m_pServer) return; const wxArrayString& files = pFileDataObject->GetFilenames(); for (unsigned int i = 0; i < files.Count(); i++) { int64_t size; bool is_link; CLocalFileSystem::local_fileType type = CLocalFileSystem::GetFileInfo(files[i], is_link, &size, 0, 0); if (type == CLocalFileSystem::file) { wxString localFile; const CLocalPath localPath(files[i], &localFile); m_pMainFrame->GetQueue()->QueueFile(queueOnly, false, localFile, wxEmptyString, localPath, path, *m_pServer, size); m_pMainFrame->GetQueue()->QueueFile_Finish(!queueOnly); } else if (type == CLocalFileSystem::dir) { CLocalPath localPath(files[i]); if (localPath.HasParent()) { CServerPath target = path; target.AddSegment(localPath.GetLastSegment()); m_pMainFrame->GetQueue()->QueueFolder(queueOnly, false, localPath, target, *m_pServer); } } } }
IFXRESULT IFXOSFileIterator::GetPlugins( IFXString *subPath ) { IFXRESULT result = IFX_OK; WIN32_FIND_DATA data; BOOL res = FALSE; HANDLE hdl; IFXString tempPath; // find and store all files in this dir ProcessDir( subPath ); // now process subdirs IFXString localPath( m_pluginLocation ); localPath.Concatenate( subPath ); localPath.Concatenate( IFXOSFI_EXTALL ); hdl = FindFirstFile( localPath.Raw(), &data ); // if there are no any file/directory then skip next block if( INVALID_HANDLE_VALUE != hdl ) { // keep searching while there are any files/directories do { // create full path to the found object tempPath.Assign( &m_pluginLocation ); tempPath.Concatenate( subPath ); tempPath.Concatenate( data.cFileName ); // we already found and stored all files we wanted, so check if found object is // a) a directory, // b) its nesting doesn't exceed the limitation (IFXOSFI_MAXDEPTH), // c) its name isn't a "." or ".." if( IsDir( &tempPath ) > 0 && m_depth < IFXOSFI_MAXDEPTH && wcscmp( data.cFileName, IFXOSFI_CURRDIR ) && wcscmp( data.cFileName, IFXOSFI_UPPRDIR ) ) { // we have found a directory and we want to look in it, so // create its relative path: tempPath.Assign( subPath ); tempPath.Concatenate( data.cFileName ); tempPath.Concatenate( L"\\" ); // increment the depth (nesting) m_depth++; // step inside GetPlugins( &tempPath ); // decrement the depth (nesting) m_depth--; } // find next file/directory res = FindNextFile( hdl, &data ); } while( res ); // close handle FindClose( hdl ); } return result; }
void Folder::slotLocalPathChanged( const QString& dir ) { QDir notifiedDir(dir); QDir localPath(_path ); if( notifiedDir == localPath ) { if( !localPath.exists() ) { qDebug() << "ALARM: The local path was DELETED!"; } } }
void CLocalListView::OnMenuUpload(wxCommandEvent& event) { const CServer* pServer = m_pState->GetServer(); if (!pServer) { wxBell(); return; } bool added = false; bool queue_only = event.GetId() == XRCID("ID_ADDTOQUEUE"); long item = -1; for (;;) { item = GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); if (!item && m_hasParent) continue; if (item == -1) break; const CLocalFileData *data = GetData(item); if (!data) break; if (data->flags == fill) continue; CServerPath path = m_pState->GetRemotePath(); if (path.IsEmpty()) { wxBell(); break; } if (data->dir) { path.ChangePath(data->name); CLocalPath localPath(m_dir); localPath.AddSegment(data->name); m_pQueue->QueueFolder(event.GetId() == XRCID("ID_ADDTOQUEUE"), false, localPath, path, *pServer); } else { m_pQueue->QueueFile(queue_only, false, data->name, wxEmptyString, CLocalPath(m_dir), path, *pServer, data->size); added = true; } } if (added) m_pQueue->QueueFile_Finish(!queue_only); }
void Bundle::loadProperties() { Path localPath(false); localPath.pushDirectory(_language.primaryTag()); localPath.pushDirectory(_language.subTags()); while (localPath.depth() > 0) { Path resPath(localPath, PROPERTIES_FILE); addProperties(resPath.toString(Path::PATH_UNIX)); localPath.popDirectory(); } addProperties(PROPERTIES_FILE); }
bool KFileItemPrivate::isSlow() const { if (m_slow == SlowUnknown) { const QString path = localPath(); if (!path.isEmpty()) { const KFileSystemType::Type fsType = KFileSystemType::fileSystemType(path); m_slow = (fsType == KFileSystemType::Nfs || fsType == KFileSystemType::Smb) ? Slow : Fast; } else { m_slow = Slow; } } return m_slow == Slow; }
/** * SendFile * * Description: Send a file from the local repository to the ftp server. * * Param con - describes the ftp server to send to. * file - describes file path and name to copy. * waitDialog - notification target. * * Return bool - not currently used. */ bool CFtpManager::SendFile(CConnection * con, CFileContainer & file, CWaitDialog & waitDialog) { bool result = false; CString localStorePath; GetLocalStorePath(con, localStorePath); CString localPath(localStorePath + file.path + file.name); localPath.Replace('/', '\\'); CString destinationPath(file.path + file.name); // Get file size CFileStatus filestatus; CFile::GetStatus( localPath, filestatus ); //CUT_FTPClient * ftpClient = new CUT_FTPClient(); CRealFtpClient * ftpClient = new CRealFtpClient(); ftpClient->fileSize = filestatus.m_size; ftpClient->m_waitDialog = &waitDialog; ftpClient->con = con; // depricate -> moved into FileTransfer CFileTransfer * transfer = new CFileTransfer(); transfer->sending = true; CConnection * conClone = new CConnection(con); transfer->connection = conClone; transfer->fileName = file.name; ftpClient->m_transfer = transfer; // increment files being transfered count if(waitDialog){ // inc } FTP_THREADPARAM * _param = new FTP_THREADPARAM; _param->c = this; _param->con = con; _param->localPath = localPath; _param->remotePath = destinationPath; _param->ftpClient = ftpClient; _param->fileSize = filestatus.m_size; _param->waitDialog = &waitDialog; //CWinThread *pSendFileThread; m_pSendFileThread = AfxBeginThread(CFtpManager::SendFileWorker, _param); if (m_pSendFileThread != NULL) { //TRACE(_T("AfxBeginThread: 0x%08lX\n"), m_pSendFileThread->m_nThreadID); //m_transferThreads->push_back(pSendFileThread); } return result; }
JNIEXPORT void JNICALL Java_org_apache_subversion_javahl_SVNClient_merge__Ljava_lang_String_2Lorg_apache_subversion_javahl_types_Revision_2Ljava_util_List_2Ljava_lang_String_2ZLorg_apache_subversion_javahl_types_Depth_2ZZZ (JNIEnv *env, jobject jthis, jstring jpath, jobject jpegRevision, jobject jranges, jstring jlocalPath, jboolean jforce, jobject jdepth, jboolean jignoreAncestry, jboolean jdryRun, jboolean jrecordOnly) { JNIEntry(SVNClient, merge); SVNClient *cl = SVNClient::getCppObject(jthis); if (cl == NULL) { JNIUtil::throwError(_("bad C++ this")); return; } JNIStringHolder path(jpath); if (JNIUtil::isExceptionThrown()) return; Revision pegRevision(jpegRevision); if (JNIUtil::isExceptionThrown()) return; JNIStringHolder localPath(jlocalPath); if (JNIUtil::isExceptionThrown()) return; // Build the revision range vector from the Java array. Array ranges(jranges); if (JNIUtil::isExceptionThrown()) return; std::vector<RevisionRange> revisionRanges; std::vector<jobject> rangeVec = ranges.vector(); for (std::vector<jobject>::const_iterator it = rangeVec.begin(); it < rangeVec.end(); ++it) { RevisionRange revisionRange(*it); if (JNIUtil::isExceptionThrown()) return; revisionRanges.push_back(revisionRange); } cl->merge(path, pegRevision, revisionRanges, localPath, jforce ? true:false, EnumMapper::toDepth(jdepth), jignoreAncestry ? true:false, jdryRun ? true:false, jrecordOnly ? true:false); }
std::istream* Bundle::getLocalizedResource(const std::string& name, const LanguageTag& language) const { Path localPath(false); localPath.pushDirectory(language.primaryTag()); localPath.pushDirectory(language.subTags()); Path resPath(localPath, name); std::istream* pStream = getResource(resPath.toString(Path::PATH_UNIX)); while (!pStream && localPath.depth() > 0) { localPath.popDirectory(); resPath = Path(localPath, name); pStream = getResource(resPath.toString(Path::PATH_UNIX)); } return pStream; }
static JSValueRef pathToLocalResourceCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { if (argumentCount < 1) return JSValueMakeUndefined(context); LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); JSRetainPtr<JSStringRef> localPath(Adopt, JSValueToStringCopy(context, arguments[0], exception)); ASSERT(!*exception); JSRetainPtr<JSStringRef> convertedPath(Adopt, controller->pathToLocalResource(context, localPath.get())); if (!convertedPath) return JSValueMakeUndefined(context); return JSValueMakeString(context, convertedPath.get()); }
/** * IsFolderLocal * * Description: Determine if a folder is local and up to date. If it is not it may * need to be downloaded. */ bool CFtpManager::IsFolderLocal(CConnection * con, CFileContainer & file) { bool result = true; CString localStorePath; GetLocalStorePath(con, localStorePath); CString localPath(localStorePath + file.path + file.name); localPath.Replace('/', '\\'); CFtpManager ftp; // Read directory information, process subfolders. std::vector<CFileContainer> files; bool r = ftp.ReadLocalDirectory(con, CString( file.path + file.name + _T("/") ), files); if(r == false) // failed because it hasn't been downloaded yet. { ftp.GetFtpDirectory(con, CString( file.path + file.name + _T("/") ), NULL); ftp.ReadLocalDirectory(con, CString( file.path + file.name + _T("/") ), files); } int i = 0; for(i = 0; i < files.size(); i++) { CFileContainer f; f = (CFileContainer)files[i]; bool descend = true; if(f.dir) // dir { //CString subFolder(CString(f.path + f.name + _T("/"))); result = IsFolderLocal(con, f); } else // file { CString sFile; sFile = CString(localStorePath + f.path + f.name); sFile.Replace('/', '\\'); if ( 0xFFFFFFFF == GetFileAttributes ( sFile ) && GetLastError() == ERROR_FILE_NOT_FOUND ) { return false; } } } return result; }
IFXRESULT IFXOSFileIterator::ProcessDir( IFXString *subPath ) { HANDLE hdl; BOOL isDone = FALSE; WIN32_FIND_DATA data; IFXRESULT res = IFX_OK; IFXString tempPath; IFXString localPath( m_pluginLocation ); localPath.Concatenate( subPath ); localPath.Concatenate( m_filesExtension ); hdl = FindFirstFile( localPath.Raw(), &data ); if( INVALID_HANDLE_VALUE == hdl ) { isDone = TRUE; // no files were found } if( !isDone ) { // do it while there are any files left do { // create full path to the found object tempPath.Assign( &m_pluginLocation ); tempPath.Concatenate( subPath ); tempPath.Concatenate( data.cFileName ); // if it is not a dir then record file name if( !IsDir( &tempPath ) ) { m_plugins.Concatenate( subPath ); m_plugins.Concatenate( data.cFileName ); m_plugins.Concatenate( IFXOSFI_DELIM ); // increment plugins count m_count++; } } while( FindNextFile( hdl, &data ) ); // close handle FindClose( hdl ); } return res; }
QUrl DownloadJob::prepareFilename() { QString filename = QString( "%1. %2.%3" ).arg( m_track->albumpos() ).arg( safeEncode( m_track->track() ) ).arg( m_format.extension ); QString path = localPath(); QString localFile = QString( path + "/" + filename ); if ( !m_tryResuming ) { QFileInfo fileInfo( localFile ); unsigned int dupe = 1; while ( dupe < 100 ) { QFileInfo fi( localFile ); if ( fi.exists() ) { QString dupeToken = QString( " (%1)" ).arg( dupe++ ); localFile = path + "/" + fileInfo.completeBaseName() + dupeToken + "." + fileInfo.suffix(); } else break; } } else { QFileInfo fileInfo( localFile ); unsigned int dupe = 1; QString lastFound = localFile; while ( dupe < 100 ) { QFileInfo fi( localFile ); if ( fi.exists() ) { lastFound = localFile; QString dupeToken = QString( " (%1)" ).arg( dupe++ ); localFile = path + "/" + fileInfo.completeBaseName() + dupeToken + "." + fileInfo.suffix(); } else break; } localFile = lastFound; } tLog() << "Storing file as" << localFile << m_tryResuming; return QUrl( localFile ); }
KUrl KFileItem::mostLocalUrl(bool &local) const { QString local_path = localPath(); if ( !local_path.isEmpty() ) { local = true; KUrl url; url.setPath(local_path); return url; } else { local = d->m_bIsLocalUrl; return d->m_url; } }
KURL KFileItem::mostLocalURL(bool &local) const { QString local_path = localPath(); if ( !local_path.isEmpty() ) { local = true; KURL url; url.setPath(local_path); return url; } else { local = m_bIsLocalURL; return m_url; } }
void ownCloudFolder::slotLocalPathChanged( const QString& dir ) { QDir notifiedDir(dir); QDir localPath( path() ); if( notifiedDir.absolutePath() == localPath.absolutePath() ) { if( !localPath.exists() ) { qDebug() << "XXXXXXX The sync folder root was removed!!"; if( _thread && _thread->isRunning() ) { qDebug() << "CSync currently running, set wipe flag!!"; } else { qDebug() << "CSync not running, wipe it now!!"; wipe(); } qDebug() << "ALARM: The local path was DELETED!"; } } }
/** * ReceiveFile * * Description: Starts a receive transfer in a new thread. If multiple * file transfers are requested in the same operation the same waitDialog is used to track them. */ bool CFtpManager::ReceiveFile(CConnection * con, CFileContainer & file, CWaitDialog & waitDialog) { bool result = false; CString localStorePath; GetLocalStorePath(con, localStorePath); CString localPath(localStorePath + file.path + file.name); localPath.Replace('/', '\\'); CString remotePath(file.path + file.name); CRealFtpClient * ftpClient = new CRealFtpClient(); ftpClient->fileSize = file.size; ftpClient->m_waitDialog = &waitDialog; ftpClient->con = con; CFileTransfer * transfer = new CFileTransfer(); transfer->sending = false; CConnection * conClone = new CConnection(con); transfer->connection = conClone; transfer->fileName = file.name; ftpClient->m_transfer = transfer; FTP_THREADPARAM * _param = new FTP_THREADPARAM; _param->c = this; _param->con = con; _param->localPath = localPath; _param->remotePath = remotePath; _param->ftpClient = ftpClient; _param->fileSize = file.size; _param->waitDialog = &waitDialog; m_pReceiveFileThread = AfxBeginThread(CFtpManager::ReceiveFileWorker, _param); if (m_pReceiveFileThread != NULL) { //TRACE(_T("AfxBeginThread: 0x%08lX\n"), m_pReceiveFileThread->m_nThreadID); result = true; } return result; }
JNIEXPORT void JNICALL Java_org_apache_subversion_javahl_SVNClient_merge__Ljava_lang_String_2Lorg_apache_subversion_javahl_types_Revision_2Ljava_lang_String_2Lorg_apache_subversion_javahl_types_Revision_2Ljava_lang_String_2ZLorg_apache_subversion_javahl_types_Depth_2ZZZ (JNIEnv *env, jobject jthis, jstring jpath1, jobject jrevision1, jstring jpath2, jobject jrevision2, jstring jlocalPath, jboolean jforce, jobject jdepth, jboolean jignoreAncestry, jboolean jdryRun, jboolean jrecordOnly) { JNIEntry(SVNClient, merge); SVNClient *cl = SVNClient::getCppObject(jthis); if (cl == NULL) { JNIUtil::throwError(_("bad C++ this")); return; } Revision revision1(jrevision1); if (JNIUtil::isExceptionThrown()) return; JNIStringHolder path1(jpath1); if (JNIUtil::isExceptionThrown()) return; Revision revision2(jrevision2); if (JNIUtil::isExceptionThrown()) return; JNIStringHolder path2(jpath2); if (JNIUtil::isExceptionThrown()) return; JNIStringHolder localPath(jlocalPath); if (JNIUtil::isExceptionThrown()) return; cl->merge(path1, revision1, path2, revision2, localPath, jforce ? true:false, EnumMapper::toDepth(jdepth), jignoreAncestry ? true:false, jdryRun ? true:false, jrecordOnly ? true:false); }
/** * DeleteFile * * Description: Delete a file from the local system and remote FTP server. * TODO: multi file select * Parameters: CFileContainer contains identification for file to be removed * * Returns: bool true if deleted, false if not deleted. */ bool CFtpManager::DeleteFile(CConnection * con, CFileContainer & file) { bool result = false; CString localStorePath; GetLocalStorePath(con, localStorePath); CString localPath(localStorePath + file.path + file.name); localPath.Replace('/', '\\'); CString remotePath(file.path + file.name); //TRACE2("localPath %s remotePath %s \n", localPath, remotePath); // Delete from FTP server if(!m_ftpClient.IsConnected()) { int retcode = 11; retcode = m_ftpClient.FTPConnect(con->host, con->user, con->password, _T("")); if(retcode == UTE_SUCCESS) { } } m_ftpClient.SetFireWallMode(TRUE); int r = m_ftpClient.DeleteFileW(remotePath); if(r == UTE_SUCCESS) { result = true; } // Delete from local disk CFile::Remove(localPath); // Reload dir listing info from server GetFtpDirectory(con, file.path); return result; }
void ProcessRequest(ServerSettings *settings) { int i; for(i=0;i < settings->NumOfRequest; i++) { char *req_path = workload_get_path(); if(strlen(req_path) > 256) { fprintf(stderr, "Request path exceeded maximum of 256 characters\n"); exit(EXIT_FAILURE); } if(req_path == NULL) { fprintf(stderr, "Request path cannot be NULL or empty\n"); exit(EXIT_FAILURE); } printf("Processing request\n"); FILE *file; char local_path[512]; int returncode; localPath(req_path, local_path); pthread_mutex_lock(&_fileLock); file = openFile(local_path); gfcrequest_t *gfr; gfr = gfc_create(); gfc_set_server(gfr, settings->Server); gfc_set_path(gfr, req_path); gfc_set_port(gfr, settings->Port); gfc_set_writefunc(gfr, writecb); gfc_set_writearg(gfr, file); fprintf(stdout, "Requesting %s%s\n", settings->Server, req_path); if ( 0 > (returncode = gfc_perform(gfr))) { fprintf(stdout, "gfc_perform returned an error %d\n", returncode); fclose(file); if ( 0 > unlink(local_path)) { fprintf(stderr, "unlink failed on %s\n", local_path); } } else { fclose(file); } pthread_mutex_unlock(&_fileLock); if ( gfc_get_status(gfr) != GF_OK) { if ( 0 > unlink(local_path)) { fprintf(stderr, "unlink failed on %s\n", local_path); } } fprintf(stdout, "Status: %s\n", gfc_strstatus(gfc_get_status(gfr))); fprintf(stdout, "Received %zu of %zu bytes\n", gfc_get_bytesreceived(gfr), gfc_get_filelen(gfr)); } pthread_exit(NULL); free(settings); }
as_object* SharedObjectLibrary::getLocal(const std::string& objName, const std::string& root) { assert (!objName.empty()); // already warned about it at construction time if (_solSafeDir.empty()) return 0; if (rcfile.getSOLLocalDomain() && !_baseDomain.empty()) { log_security("Attempting to open SOL file from non " "localhost-loaded SWF"); return 0; } // Check that the name is valid; if not, return null if (!validateName(objName)) return 0; // The 'root' argument, otherwise known as localPath, specifies where // in the SWF path the SOL should be stored. It cannot be outside this // path. std::string requestedPath; // If a root is specified, check it first for validity if (!root.empty()) { const movie_root& mr = _vm.getRoot(); const std::string& swfURL = mr.getOriginalURL(); // The specified root may or may not have a domain. If it doesn't, // this constructor will add the SWF's domain. URL localPath(root, swfURL); StringNoCaseEqual noCaseCompare; // All we care about is whether the domains match. They may be // empty filesystem-loaded. if (!noCaseCompare(localPath.hostname(), _baseDomain)) { log_security(_("SharedObject path %s is outside the SWF domain " "%s. Cannot access this object."), localPath, _baseDomain); return 0; } requestedPath = localPath.path(); // The domains match. Now check that the path is a sub-path of // the SWF's URL. It is done by case-insensitive string comparison, // so a double slash in the requested path will fail. if (!noCaseCompare(requestedPath, _basePath.substr(0, requestedPath.size()))) { log_security(_("SharedObject path %s is not part of the SWF path " "%s. Cannot access this object."), requestedPath, _basePath); return 0; } } // A leading slash is added later std::ostringstream solPath; // If the domain name is empty, the SWF was loaded from the filesystem. // Use "localhost". solPath << (_baseDomain.empty() ? "localhost" : _baseDomain); // Paths should start with a '/', so we shouldn't have to add another // one. assert(requestedPath.empty() ? _basePath[0] == '/' : requestedPath[0] == '/'); // If no path was requested, use the SWF's path. solPath << (requestedPath.empty() ? _basePath : requestedPath) << "/" << objName; // TODO: normalize key! const std::string& key = solPath.str(); // If the shared object was already opened, use it. SoLib::iterator it = _soLib.find(key); if (it != _soLib.end()) { log_debug("SharedObject %s already known, returning it", key); return &it->second->owner(); } log_debug("SharedObject %s not loaded. Loading it now", key); // Otherwise create a new one and register to the lib SharedObject_as* sh = createSharedObject(*_vm.getGlobal()); if (!sh) return 0; sh->setObjectName(objName); std::string newspec = _solSafeDir; newspec += "/"; newspec += key; newspec += ".sol"; sh->setFilespec(newspec); log_debug("SharedObject path: %s", newspec); as_object* data = readSOL(_vm, newspec); /// Don't set to 0, or it will initialize a property. if (data) sh->setData(data); // The SharedObjectLibrary must set this as reachable. _soLib[key] = sh; return &sh->owner(); }
void Inference::go() { if (m_pool || m_valid) { throw std::runtime_error("Cannot call Inference::go twice"); } m_pool = makeUnique<Pool>(m_threads); const std::size_t size(m_fileInfo.size()); for (std::size_t i(0); i < size; ++i) { FileInfo& f(m_fileInfo[i]); m_index = i; if (m_verbose) { std::cout << i + 1 << " / " << size << ": " << f.path() << std::endl; } if (m_executor.good(f.path())) { m_valid = true; if (m_arbiter->isHttpDerived(f.path())) { m_pool->add([this, &f]() { const auto data(m_arbiter->getBinary(f.path(), range)); std::string name(f.path()); std::replace(name.begin(), name.end(), '/', '-'); std::replace(name.begin(), name.end(), '\\', '-'); m_tmp.put(name, data); add(m_tmp.fullPath(name), f); arbiter::fs::remove(m_tmp.fullPath(name)); }); } else { m_pool->add([&f, this]() { auto localHandle( m_arbiter->getLocalHandle(f.path(), m_tmp)); add(localHandle->localPath(), f); }); } } else { f.status(FileInfo::Status::Omitted); } } m_pool->join(); if (!m_valid) { throw std::runtime_error("No point cloud files found"); } aggregate(); makeSchema(); if (!numPoints()) { throw std::runtime_error("Zero points found"); } else if (!schema().pointSize()) { throw std::runtime_error("No schema dimensions found"); } else if (bounds() == Bounds::expander()) { throw std::runtime_error("No bounds found"); } if (m_cesiumify) { std::cout << "Transforming inference" << std::endl; m_transformation = makeUnique<Transformation>(calcTransformation()); m_bounds = makeUnique<Bounds>(Bounds::expander()); for (auto& f : m_fileInfo) { if (!f.bounds()) throw std::runtime_error("No bounds present"); f.bounds(m_executor.transform(*f.bounds(), *m_transformation)); m_bounds->grow(*f.bounds()); } } m_done = true; }
void CManualTransfer::OnOK(wxCommandEvent& event) { if (!UpdateServer()) return; bool download = XRCCTRL(*this, "ID_DOWNLOAD", wxRadioButton)->GetValue(); bool start = XRCCTRL(*this, "ID_START", wxCheckBox)->GetValue(); if (!m_pServer) { wxMessageBoxEx(_("You need to specify a server."), _("Manual transfer"), wxICON_EXCLAMATION); return; } wxString local_file = XRCCTRL(*this, "ID_LOCALFILE", wxTextCtrl)->GetValue(); if (local_file == _T("")) { wxMessageBoxEx(_("You need to specify a local file."), _("Manual transfer"), wxICON_EXCLAMATION); return; } CLocalFileSystem::local_fileType type = CLocalFileSystem::GetFileType(local_file); if (type == CLocalFileSystem::dir) { wxMessageBoxEx(_("Local file is a directory instead of a regular file."), _("Manual transfer"), wxICON_EXCLAMATION); return; } if (!download && type != CLocalFileSystem::file && start) { wxMessageBoxEx(_("Local file does not exist."), _("Manual transfer"), wxICON_EXCLAMATION); return; } wxString remote_file = XRCCTRL(*this, "ID_REMOTEFILE", wxTextCtrl)->GetValue(); if (remote_file == _T("")) { wxMessageBoxEx(_("You need to specify a remote file."), _("Manual transfer"), wxICON_EXCLAMATION); return; } wxString remote_path_str = XRCCTRL(*this, "ID_REMOTEPATH", wxTextCtrl)->GetValue(); if (remote_path_str == _T("")) { wxMessageBoxEx(_("You need to specify a remote path."), _("Manual transfer"), wxICON_EXCLAMATION); return; } CServerPath path(remote_path_str, m_pServer->GetType()); if (path.IsEmpty()) { wxMessageBoxEx(_("Remote path could not be parsed."), _("Manual transfer"), wxICON_EXCLAMATION); return; } int old_data_type = COptions::Get()->GetOptionVal(OPTION_ASCIIBINARY); // Set data type for the file to add if (XRCCTRL(*this, "ID_TYPE_ASCII", wxRadioButton)->GetValue()) COptions::Get()->SetOption(OPTION_ASCIIBINARY, 1); else if (XRCCTRL(*this, "ID_TYPE_BINARY", wxRadioButton)->GetValue()) COptions::Get()->SetOption(OPTION_ASCIIBINARY, 2); else COptions::Get()->SetOption(OPTION_ASCIIBINARY, 0); wxString name; CLocalPath localPath(local_file, &name); if (name.empty()) { wxMessageBoxEx(_("Local file is not a valid filename."), _("Manual transfer"), wxICON_EXCLAMATION); return; } m_pQueueView->QueueFile(!start, download, download ? remote_file : name, (remote_file != name) ? (download ? name : remote_file) : wxString(), localPath, path, *m_pServer, -1); // Restore old data type COptions::Get()->SetOption(OPTION_ASCIIBINARY, old_data_type); m_pQueueView->QueueFile_Finish(start); EndModal(wxID_OK); }
/* Main ========================================================= */ int main(int argc, char **argv) { /* COMMAND LINE OPTIONS ============================================= */ char *server = "localhost"; unsigned short port = 8888; char *workload_path = "workload.txt"; int i; int option_char = 0; int nrequests = 1; int nthreads = 1; int returncode; gfcrequest_t *gfr; FILE *file; char *req_path; char local_path[512]; // Parse and set command line arguments while ((option_char = getopt_long(argc, argv, "s:p:w:n:t:h", gLongOptions, NULL)) != -1) { switch (option_char) { case 's': // server server = optarg; break; case 'p': // port port = atoi(optarg); break; case 'w': // workload-path workload_path = optarg; break; case 'n': // nrequests nrequests = atoi(optarg); break; case 't': // nthreads nthreads = atoi(optarg); if(nthreads != 1){ fprintf(stderr, "Multiple threads not yet supported.\n"); exit(0); } break; case 'h': // help Usage(); exit(0); break; default: Usage(); exit(1); } } if( EXIT_SUCCESS != workload_init(workload_path)){ fprintf(stderr, "Unable to load workload file %s.\n", workload_path); exit(EXIT_FAILURE); } gfc_global_init(); /*Making the requests...*/ for(i = 0; i < nrequests * nthreads; i++){ req_path = workload_get_path(); if(strlen(req_path) > 256){ fprintf(stderr, "Request path exceeded maximum of 256 characters\n."); exit(EXIT_FAILURE); } localPath(req_path, local_path); file = openFile(local_path); gfr = gfc_create(); gfc_set_server(gfr, server); gfc_set_path(gfr, req_path); gfc_set_port(gfr, port); gfc_set_writefunc(gfr, writecb); gfc_set_writearg(gfr, file); fprintf(stdout, "Requesting %s%s\n", server, req_path); if ( 0 > (returncode = gfc_perform(gfr))){ fprintf(stdout, "gfc_perform returned an error %d\n", returncode); fclose(file); if ( 0 > unlink(local_path)) fprintf(stderr, "unlink failed on %s\n", local_path); } else { fclose(file); } if ( gfc_get_status(gfr) != GF_OK){ if ( 0 > unlink(local_path)) fprintf(stderr, "unlink failed on %s\n", local_path); } fprintf(stdout, "Status: %s\n", gfc_strstatus(gfc_get_status(gfr))); fprintf(stdout, "Received %zu of %zu bytes\n", gfc_get_bytesreceived(gfr), gfc_get_filelen(gfr)); } gfc_global_cleanup(); return 0; }