int RodsConnection::removeColl(const std::string &collPath) { collInp_t theColl; int status = 0; // sanity check, input argument string must be nonempty and begin with / if (collPath.empty() || collPath.find_first_of('/') != 0) return (-1); this->mutexLock(); // initialize rods api struct memset(&theColl, 0, sizeof (collInp_t)); rstrcpy(theColl.collName, collPath.c_str(), MAX_NAME_LEN); // initialize parameters for remove operation addKeyVal(&theColl.condInput, RECURSIVE_OPR__KW, ""); addKeyVal(&theColl.condInput, FORCE_FLAG_KW, ""); // call for rods api to remove collection status = rcRmColl(this->rodsCommPtr, &theColl, false); this->mutexUnlock(); // return status to caller return (status); }
int rmdirCollUtil( rcComm_t *conn, rodsArguments_t *myRodsArgs, int treatAsPathname, rodsPath_t collPath ) { int status; collInp_t collInp; dataObjInp_t dataObjInp; if ( !checkCollExists( conn, myRodsArgs, collPath.outPath ) ) { std::cout << "Failed to remove [" << collPath.outPath << "]: Collection does not exist" << std::endl; return 0; } // check to make sure it's not /, /home, or /home/username? // XXXXX if ( !checkCollIsEmpty( conn, myRodsArgs, collPath.outPath ) ) { std::cout << "Failed to remove [" << collPath.outPath << "]: Collection is not empty" << std::endl; return 0; } else { initCondForRm( myRodsArgs, &dataObjInp, &collInp ); rstrcpy( collInp.collName, collPath.outPath, MAX_NAME_LEN ); status = rcRmColl( conn, &collInp, myRodsArgs->verbose ); if ( status < 0 ) { std::cout << "rmdirColl: rcRmColl failed with error " << status << std::endl; return status; } if ( treatAsPathname ) { return rmdirCollUtil( conn, myRodsArgs, treatAsPathname, getParentColl( collPath.outPath ) ); } else { return status; } } return 0; }
int irods_reli_rmdir ( const char *host, const char *path ) { collInp_t request; int result; /* Note that an irods rmdir will fail silently if you attempt to remove a non-directory. So, first we must examine the type and fail explicitly if it is not a dir. */ struct pfs_stat info; result = irods_reli_stat(host,path,&info); if(result<0) return result; if(!S_ISDIR(info.st_mode)) { errno = EISDIR; return -1; } struct irods_server *server = connect_to_host(host); if(!server) return -1; memset(&request,0,sizeof(request)); strcpy(request.collName,path); addKeyVal (&request.condInput, FORCE_FLAG_KW, ""); debug(D_IRODS,"rcRmColl %s %s",host,path); result = rcRmColl(server->conn,&request,0); debug(D_IRODS,"= %d",result); clearKeyVal (&request.condInput); if(result<0) { errno = irods_reli_errno(result); return -1; } return result; }
int irodsRmdir (const char *path) { collInp_t collInp; int status; iFuseConn_t *iFuseConn = NULL; rodsLog (LOG_DEBUG, "irodsRmdir: %s", path); memset (&collInp, 0, sizeof (collInp)); status = parseRodsPathStr ((char *) (path + 1) , &MyRodsEnv, collInp.collName); if (status < 0) { rodsLogError (LOG_ERROR, status, "irodsRmdir: parseRodsPathStr of %s error", path); /* use ENOTDIR for this type of error */ return -ENOTDIR; } addKeyVal (&collInp.condInput, FORCE_FLAG_KW, ""); getAndUseIFuseConn (&iFuseConn, &MyRodsEnv); RECONNECT_IF_NECESSARY(status, iFuseConn, rcRmColl (iFuseConn->conn, &collInp, 0)); if (status >= 0) { #ifdef CACHE_FUSE_PATH pathNotExist ((char *) path); #endif status = 0; } else { rodsLogError (LOG_ERROR, status, "irodsRmdir: rcRmColl of %s error", path); status = -ENOENT; } unuseIFuseConn (iFuseConn); clearKeyVal (&collInp.condInput); return (status); }