QList<br::FilesWithLabel> br::getFilesWithLabels(QDir dir) { dir = QDir(dir.canonicalPath()); QStringList files; foreach (const QString &file, dir.entryList(QDir::Files)) files.append(dir.absoluteFilePath(file)); QList<br::FilesWithLabel> filesWithLabels; filesWithLabels.append(br::FilesWithLabel(dir.dirName(),files)); foreach (const QString &folder, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) { QDir subdir(dir); bool success = subdir.cd(folder); if (!success) qFatal("cd failure."); filesWithLabels.append(getFilesWithLabels(subdir)); } return filesWithLabels; }
TEST(adb_utils, directory_exists) { #ifdef _WIN32 char profiles_dir[MAX_PATH]; DWORD cch = arraysize(profiles_dir); // On typical Windows 7, returns C:\Users ASSERT_TRUE(GetProfilesDirectory(profiles_dir, &cch)); ASSERT_TRUE(directory_exists(profiles_dir)); // On modern (English?) Windows, this is a directory symbolic link to // C:\ProgramData. Symbolic links are rare on Windows and the user requires // a special permission (by default granted to Administrative users) to // create symbolic links. ASSERT_FALSE(directory_exists(subdir(profiles_dir, "All Users"))); // On modern (English?) Windows, this is a directory junction to // C:\Users\Default. Junctions are used throughout user profile directories // for backwards compatibility and they don't require any special permissions // to create. ASSERT_FALSE(directory_exists(subdir(profiles_dir, "Default User"))); ASSERT_FALSE(directory_exists(subdir(profiles_dir, "does-not-exist"))); #else ASSERT_TRUE(directory_exists("/proc")); ASSERT_FALSE(directory_exists("/proc/self")); // Symbolic link. ASSERT_FALSE(directory_exists("/proc/does-not-exist")); #endif }
int main(int argc, char *argv[]) { struct iovec *iov; char *p, *val; char source[MAXPATHLEN]; char target[MAXPATHLEN]; char errmsg[255]; int ch, iovlen; char nullfs[] = "nullfs"; iov = NULL; iovlen = 0; errmsg[0] = '\0'; while ((ch = getopt(argc, argv, "o:")) != -1) switch(ch) { case 'o': val = strdup(""); p = strchr(optarg, '='); if (p != NULL) { free(val); *p = '\0'; val = p + 1; } build_iovec(&iov, &iovlen, optarg, val, (size_t)-1); break; case '?': default: usage(); } argc -= optind; argv += optind; if (argc != 2) usage(); /* resolve target and source with realpath(3) */ if (checkpath(argv[0], target) != 0) err(EX_USAGE, "%s", target); if (checkpath(argv[1], source) != 0) err(EX_USAGE, "%s", source); if (subdir(target, source) || subdir(source, target)) errx(EX_USAGE, "%s (%s) and %s are not distinct paths", argv[0], target, argv[1]); build_iovec(&iov, &iovlen, "fstype", nullfs, (size_t)-1); build_iovec(&iov, &iovlen, "fspath", source, (size_t)-1); build_iovec(&iov, &iovlen, "target", target, (size_t)-1); build_iovec(&iov, &iovlen, "errmsg", errmsg, sizeof(errmsg)); if (nmount(iov, iovlen, 0) < 0) { if (errmsg[0] != 0) err(1, "%s: %s", source, errmsg); else err(1, "%s", source); } exit(0); }
int main(int argc, char *argv[]) { struct iovec iov[6]; int ch, mntflags; char source[MAXPATHLEN]; char target[MAXPATHLEN]; mntflags = 0; while ((ch = getopt(argc, argv, "o:")) != -1) switch(ch) { case 'o': getmntopts(optarg, mopts, &mntflags, 0); break; case '?': default: usage(); } argc -= optind; argv += optind; if (argc != 2) usage(); /* resolve target and source with realpath(3) */ if (checkpath(argv[0], target) != 0) err(EX_USAGE, "%s", target); if (checkpath(argv[1], source) != 0) err(EX_USAGE, "%s", source); if (subdir(target, source) || subdir(source, target)) errx(EX_USAGE, "%s (%s) and %s are not distinct paths", argv[0], target, argv[1]); iov[0].iov_base = strdup("fstype"); iov[0].iov_len = sizeof("fstype"); iov[1].iov_base = strdup("nullfs"); iov[1].iov_len = strlen(iov[1].iov_base) + 1; iov[2].iov_base = strdup("fspath"); iov[2].iov_len = sizeof("fspath"); iov[3].iov_base = source; iov[3].iov_len = strlen(source) + 1; iov[4].iov_base = strdup("target"); iov[4].iov_len = sizeof("target"); iov[5].iov_base = target; iov[5].iov_len = strlen(target) + 1; if (nmount(iov, 6, mntflags)) err(1, NULL); exit(0); }
void NewMapDialog::loadSymbolSetDir(const QDir& symbol_set_dir) { QStringList subdirs = symbol_set_dir.entryList(QDir::Dirs | QDir::Hidden | QDir::NoSymLinks | QDir::NoDotAndDotDot, QDir::NoSort); for (auto&& dir_name : subdirs) { //int scale = dir_name.toInt(); //if (scale == 0) //{ // qDebug() << dir_name + ": not a valid map scale denominator, using it as group name."; //} QDir subdir(symbol_set_dir); if (!subdir.cd(dir_name)) { qDebug("%s: cannot access this directory.", qPrintable(dir_name)); continue; } QStringList symbol_set_filters; for (auto format : FileFormats.formats()) { if (format->supportsImport()) symbol_set_filters << QStringList(format->fileExtensions()).replaceInStrings(QRegExp(QString(QLatin1Char{'^'})), QString::fromLatin1("*.")); } subdir.setNameFilters(symbol_set_filters); QFileInfoList symbol_set_files = subdir.entryInfoList(QDir::Files | QDir::Hidden | QDir::NoSymLinks | QDir::NoDotAndDotDot, QDir::Name); auto item = symbol_set_map.emplace(dir_name, QFileInfoList{}).first; item->second.append(symbol_set_files); } }
void ConfigureDlg::accept() { QFileInfo fi( m_ui.m_sourceDirLineEdit->text().trimmed() ); if ( ! fi.exists() || ! fi.isDir() ) { QMessageBox::warning( this, tr("Error"), tr("The specified source directory does not exist.")); return; } /// Checking for valid filenames is tricky. Due a rudimentary check, disallowing /// anything not in the set of characters that are valid under most modern OS platforms. QRegExp invalidChars( "[^A-Za-z0-9 ._-()[\\]]" ); QString subdir( m_ui.m_goodDirLineEdit->text().trimmed() ); if ( subdir.contains( invalidChars ) ) { QMessageBox::warning( this, tr("Error"), tr("The specified 'good' subdirectory name contains illegal characters.")); return; } subdir = m_ui.m_goodDirLineEdit->text().trimmed(); if ( subdir.contains( invalidChars ) ) { QMessageBox::warning( this, tr("Error"), tr("The specified 'bad' subdirectory name contains illegal characters.")); return; } QDialog::accept(); }
QVariant CollectionItem::data(int role) const { switch(role) { case Qt::DisplayRole: return name(); case NameRole: return name(); case PathRole: return path(); case HashRole: return hash(); case SizeRole: return size(); case SizeTextRole: return sizeText(); case SubdirRole: return subdir(); case SubdirTextRole: return subdirText(); default: return QStandardItem::data(role); } }
int main(int argc, char *argv[]) { printf("*******usertests starting*******\n\n"); printf("=====test file usertests.ran does not exists=====\n"); if(open("usertests.ran", O_RDONLY) >= 0){ printf("already ran user tests (file usertests.ran exists) -- recreate certikos_disk.img\n"); exit(); } printf("=====test file usertests.ran does not exists: ok\n\n"); close(open("usertests.ran", O_CREATE)); smallfile(); bigfile1(); createtest(); rmdot(); fourteen(); bigfile2(); subdir(); linktest(); unlinkread(); dirfile(); iref(); bigdir(); // slow printf("*******end of tests*******\n"); }
int main(int argc, char *argv[]) { printf(1, "usertests starting\n"); if(open("usertests.ran", 0) >= 0){ printf(1, "already ran user tests -- rebuild fs.img\n"); exit(); } close(open("usertests.ran", O_CREATE)); createdelete(); linkunlink(); concreate(); fourfiles(); sharedfd(); bigargtest(); bigwrite(); bigargtest(); bsstest(); sbrktest(); validatetest(); opentest(); writetest(); writetest1(); createtest(); openiputtest(); exitiputtest(); iputtest(); mem(); pipe1(); preempt(); exitwait(); rmdot(); fourteen(); bigfile(); subdir(); linktest(); unlinkread(); dirfile(); iref(); forktest(); bigdir(); // slow exectest(); exit(); }
HCdsObjectData* HCdsFileSystemReaderPrivate::scan( const HRootDir& rdir, const QString& parentId, QList<HCdsObjectData*>* result) { HLOG(H_AT, H_FUN); QDir dir = rdir.dir(); HLOG_DBG(QString("Entering directory %1").arg(dir.absolutePath())); HStorageFolder* folder = new HStorageFolder(dir.dirName(), parentId); QString id = folder->id(); HCdsObjectData* item = new HCdsObjectData(folder, dir.absolutePath()); result->append(item); QSet<QString> childIds; QFileInfoList infoList = dir.entryInfoList(QDir::Files | QDir::AllDirs | QDir::NoDotAndDotDot); for(qint32 i = 0; i < infoList.size(); ++i) { QFileInfo finfo = infoList[i]; if (finfo.isDir() && rdir.scanMode() == HRootDir::RecursiveScan) { if (QDir(finfo.absoluteFilePath()) == dir) { continue; } HRootDir subdir(QDir(finfo.absoluteFilePath()), HRootDir::RecursiveScan); HCdsObjectData* child = scan(subdir, id, result); Q_ASSERT(child); childIds.insert(child->object()->id()); continue; } HCdsObjectData* child = indexFile(finfo, id); if (child) { result->append(child); childIds.insert(child->object()->id()); } } folder->setChildIds(childIds); return item; }
wxString wxStandardPathsBase::AppendAppInfo(const wxString& dir) const { wxString subdir(dir); if ( UsesAppInfo(AppInfo_VendorName) ) { subdir = AppendPathComponent(subdir, wxTheApp->GetVendorName()); } if ( UsesAppInfo(AppInfo_AppName) ) { subdir = AppendPathComponent(subdir, wxTheApp->GetAppName()); } return subdir; }
QStringList br::getFiles(QDir dir, bool recursive) { dir = QDir(dir.canonicalPath()); QStringList files; foreach (const QString &file, QtUtils::naturalSort(dir.entryList(QDir::Files))) files.append(dir.absoluteFilePath(file)); if (!recursive) return files; foreach (const QString &folder, QtUtils::naturalSort(dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot))) { QDir subdir(dir); bool success = subdir.cd(folder); if (!success) qFatal("cd failure."); files.append(getFiles(subdir, true)); } return files; }
bool ThumbGenerator::checkGalleryDir(const QFileInfo& fi) { // try to find a highlight QDir subdir(fi.absoluteFilePath(), "*.highlight.*", QDir::Name, QDir::Files); if (subdir.count() > 0) { // check if the image format is understood QString path(subdir.entryInfoList().begin()->absoluteFilePath()); QImageReader testread(path); return testread.canRead(); } else return false; }
//! this follows the wx implementation to the letter, just substituting our own app name function wxString AppendAppName(const wxString& dir) { wxString subdir(dir); // empty string indicates that an error has occurred, don't touch it then if ( !subdir.empty() ) { const wxString appname = GetAppName(); if ( !appname.empty() ) { const wxChar ch = *(subdir.end() - 1); if ( !wxFileName::IsPathSeparator(ch) && ch != _T('.') ) subdir += wxFileName::GetPathSeparator(); subdir += appname; } } return subdir; }
void MainWindow::cleanupWorkDir(const QString &path) { QDir workDir(path); foreach (const QFileInfo &subdirInfo, workDir.entryInfoList(QDir::NoDotAndDotDot | QDir::Dirs)) { QDir subdir(subdirInfo.absoluteDir()); foreach (const QString &file, subdir.entryList(QDir::NoDotAndDotDot | QDir::Files)) { subdir.remove(file); } workDir.rmdir(subdirInfo.fileName()); } QString name(workDir.dirName()); workDir.cdUp(); workDir.rmdir(name); }
/* static */ wxString wxStandardPathsBase::AppendPathComponent(const wxString& dir, const wxString& component) { wxString subdir(dir); // empty string indicates that an error has occurred, don't touch it then if ( !subdir.empty() ) { if ( !component.empty() ) { const wxChar ch = *(subdir.end() - 1); if ( !wxFileName::IsPathSeparator(ch) && ch != wxT('.') ) subdir += wxFileName::GetPathSeparator(); subdir += component; } } return subdir; }
// Note: doesn't handle (total) sizes above 4GB static DWORD GetDirSize(const WCHAR *dir) { ScopedMem<WCHAR> dirPattern(path::Join(dir, L"*")); WIN32_FIND_DATA findData; HANDLE h = FindFirstFile(dirPattern, &findData); if (h == INVALID_HANDLE_VALUE) return 0; DWORD totalSize = 0; do { if (!(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { totalSize += findData.nFileSizeLow; } else if (!str::Eq(findData.cFileName, L".") && !str::Eq(findData.cFileName, L"..")) { ScopedMem<WCHAR> subdir(path::Join(dir, findData.cFileName)); totalSize += GetDirSize(subdir); } } while (FindNextFile(h, &findData) != 0); FindClose(h); return totalSize; }
void parseDirectory( Driver& driver, QDir& dir, bool rec, bool parseAllFiles ) { QStringList fileList; if ( parseAllFiles ) fileList = dir.entryList( QDir::Files ); else fileList = dir.entryList( "*.h;*.H;*.hh;*.hxx;*.hpp;*.tlh" ); QStringList::Iterator it = fileList.begin(); while ( it != fileList.end() ) { QString fn = dir.path() + "/" + ( *it ); ++it; driver.parseFile( fn ); } if ( rec ) { QStringList fileList = dir.entryList( QDir::Dirs ); QStringList::Iterator it = fileList.begin(); while ( it != fileList.end() ) { if ( ( *it ).startsWith( "." ) ) { ++it; continue; } QDir subdir( dir.path() + "/" + ( *it ) ); ++it; parseDirectory( driver, subdir, rec, parseAllFiles ); } } }
void Extractor::video2images(const string& filepath, ofstream& list, bool sift_jpeg) { cout << "Creating .sift files for each frame..." << endl; if (timestamps.empty()) { cerr << "Error: No GPS locations and time stamps on record! Aborting reading video..." << endl; return; } #ifdef DEBUG ofstream debug_log("debug_log_video2images.txt"); debug_log.precision(dbl::digits10); #endif // Video name vector<string> toktok = split(filepath, '/'); toktok = split(toktok[toktok.size()-1], '.'); videoName = toktok[0]; // Time of first frame local_date_time frameTime = *firstFrameTime; // Counter on the number of frames int counter = 0; // Open video file cv::VideoCapture cap(filepath); // If successful if (cap.isOpened()) { //cout << "Reading every frame of " << filepath << " and saving SIFT and GPS data..." << endl; // For all frames while (true) { cout << "\r" << counter << " frames treated. " << flush; // 1. Read next frame Image tmp; // If no next frame, then break if (!cap.read(tmp)) break; // 2. Find corresponding time stamp and, therefore, GPS coordinates // Initialize to first boost::posix_time::time_duration duration = *firstFrameTime - timestamps[0]; long min = abs( duration.total_milliseconds() ); unsigned int index = 0; // Iterate through all saved coordinates/time stamps for (auto t : timestamps) { // Compute time difference boost::posix_time::time_duration diff = frameTime - t; // Memorize the smallest difference and the pair corresponding to it if ( abs(diff.total_milliseconds()) < min) { min = diff.total_milliseconds(); index++; } // If the difference becomes <0 then we passed // the pair we were looking for. stop if ( diff.total_milliseconds() < 0 ) break; } tmp.setGPS(GPScoord[index][0], GPScoord[index][1]); // tmp.setTimeStamp(timestamps[index]); // 4. Create sub directory boost::filesystem::path subdir(videoName.c_str()); boost::filesystem::create_directory(subdir); if (sift_jpeg) { boost::filesystem::path subdir_frames((videoName + "_frames").c_str()); boost::filesystem::create_directory(subdir_frames); } // 5. Extract SIFT // tmp.computeSIFT(); if (sift_jpeg) { stringstream st; st << videoName << "_frames" << "/" << videoName << "_" << counter << "_sift.jpg"; tmp.showSIFT().write(st.str()); } // 6. Write to a text file stringstream ss; ss.precision(dbl::digits10); ss << videoName << "/" << videoName << "_" << counter << "_" << fixed << GPScoord[index][0] << "_" << GPScoord[index][1] << ".sift"; // if (!tmp.writeSIFT2file(ss.str())) // cerr << "\nError in Extractor::video2images(): could not open " << ss.str() << ". Skipping frame." << endl; list << ss.str() << endl; #ifdef DEBUG debug_log << "Time: " << frameTime.local_time() << ", GPS: " << fixed << GPScoord[index][0] << ", " << GPScoord[index][1] << endl; #endif // 7. Add info to list of frames ImgInfo info; info.GPScoord = GPScoord[index]; info.pathToSIFTfile = ss.str(); info.index = counter; frames.push_back(info); // 8. Increment time of frame frameTime += boost::posix_time::seconds(1); // Increment counter counter++; } cap.release(); cout << endl; } else { cerr << "Error: could not open " << filepath << endl; } #ifdef DEBUG debug_log.close(); #endif };
bool SubdirsMetaMakefileGenerator::init() { if(init_flag) return false; init_flag = true; bool hasError = false; // It might make sense to bequeath the CONFIG option to the recursed // projects. OTOH, one would most likely have it in all projects anyway - // either through a qmakespec, a .qmake.cache or explicitly - as otherwise // running qmake in a subdirectory would have a different auto-recurse // setting than in parent directories. bool recurse = Option::recursive == Option::QMAKE_RECURSIVE_YES || (Option::recursive == Option::QMAKE_RECURSIVE_DEFAULT && project->isRecursive()); if(recurse) { QString old_output_dir = Option::output_dir; QString old_output = Option::output.fileName(); QString oldpwd = qmake_getpwd(); QString thispwd = oldpwd; if(!thispwd.endsWith('/')) thispwd += '/'; const QStringList &subdirs = project->values("SUBDIRS"); static int recurseDepth = -1; ++recurseDepth; for(int i = 0; i < subdirs.size(); ++i) { Subdir *sub = new Subdir; sub->indent = recurseDepth; QFileInfo subdir(subdirs.at(i)); if(!project->isEmpty(subdirs.at(i) + ".file")) subdir = project->first(subdirs.at(i) + ".file"); else if(!project->isEmpty(subdirs.at(i) + ".subdir")) subdir = project->first(subdirs.at(i) + ".subdir"); QString sub_name; if(subdir.isDir()) subdir = QFileInfo(subdir.filePath() + "/" + subdir.fileName() + Option::pro_ext); else sub_name = subdir.baseName(); if(!subdir.isRelative()) { //we can try to make it relative QString subdir_path = subdir.filePath(); if(subdir_path.startsWith(thispwd)) subdir = QFileInfo(subdir_path.mid(thispwd.length())); } //handle sub project QMakeProject *sub_proj = new QMakeProject(project->properties()); for (int ind = 0; ind < sub->indent; ++ind) printf(" "); sub->input_dir = subdir.absolutePath(); if(subdir.isRelative() && old_output_dir != oldpwd) { sub->output_dir = old_output_dir + "/" + subdir.path(); printf("Reading %s [%s]\n", subdir.absoluteFilePath().toLatin1().constData(), sub->output_dir.toLatin1().constData()); } else { //what about shadow builds? sub->output_dir = sub->input_dir; printf("Reading %s\n", subdir.absoluteFilePath().toLatin1().constData()); } qmake_setpwd(sub->input_dir); Option::output_dir = sub->output_dir; bool tmpError = !sub_proj->read(subdir.fileName()); if(!sub_proj->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) { fprintf(stderr, "Project file(%s) not recursed because all requirements not met:\n\t%s\n", subdir.fileName().toLatin1().constData(), sub_proj->values("QMAKE_FAILED_REQUIREMENTS").join(" ").toLatin1().constData()); delete sub; delete sub_proj; Option::output_dir = old_output_dir; qmake_setpwd(oldpwd); continue; } else { hasError |= tmpError; } sub->makefile = MetaMakefileGenerator::createMetaGenerator(sub_proj, sub_name); if(0 && sub->makefile->type() == SUBDIRSMETATYPE) { subs.append(sub); } else { const QString output_name = Option::output.fileName(); Option::output.setFileName(sub->output_file); hasError |= !sub->makefile->write(sub->output_dir); delete sub; qmakeClearCaches(); sub = 0; Option::output.setFileName(output_name); } Option::output_dir = old_output_dir; qmake_setpwd(oldpwd); } --recurseDepth; Option::output.setFileName(old_output); Option::output_dir = old_output_dir; qmake_setpwd(oldpwd); } Subdir *self = new Subdir; self->input_dir = qmake_getpwd(); self->output_dir = Option::output_dir; if(!recurse || (!Option::output.fileName().endsWith(Option::dir_sep) && !QFileInfo(Option::output).isDir())) self->output_file = Option::output.fileName(); self->makefile = new BuildsMetaMakefileGenerator(project, name, false); self->makefile->init(); subs.append(self); return !hasError; }
/* * rename uses retry to avoid race-conditions: at least they should be minimal. * it tries to allocate all the blocks, then sanity-checks, and if the sanity- * checks fail, it tries to restart itself again. Very practical - no changes * are done until we know everything works ok.. and then all the changes can be * done in one fell swoop when we have claimed all the buffers needed. * * Anybody can rename anything with this: the permission checks are left to the * higher-level routines. */ static int do_xiafs_rename(struct inode * old_dir, const char * old_name, int old_len, struct inode * new_dir, const char * new_name, int new_len, int must_be_dir) { struct inode * old_inode, * new_inode; struct buffer_head * old_bh, * new_bh, * dir_bh; struct xiafs_direct * old_de, * old_de_pre, * new_de, * new_de_pre; int retval; try_again: old_inode = new_inode = NULL; old_bh = new_bh = dir_bh = NULL; old_bh = xiafs_find_entry(old_dir, old_name, old_len, &old_de, &old_de_pre); retval = -ENOENT; if (!old_bh) goto end_rename; old_inode = __iget(old_dir->i_sb, old_de->d_ino, 0); /* don't cross mnt-points */ if (!old_inode) goto end_rename; if (must_be_dir && !S_ISDIR(old_inode->i_mode)) goto end_rename; retval = -EPERM; if ((old_dir->i_mode & S_ISVTX) && current->fsuid != old_inode->i_uid && current->fsuid != old_dir->i_uid && !fsuser()) goto end_rename; new_bh = xiafs_find_entry(new_dir, new_name, new_len, &new_de, NULL); if (new_bh) { new_inode = __iget(new_dir->i_sb, new_de->d_ino, 0); if (!new_inode) { brelse(new_bh); new_bh = NULL; } } if (new_inode == old_inode) { retval = 0; goto end_rename; } if (new_inode && S_ISDIR(new_inode->i_mode)) { retval = -EEXIST; goto end_rename; } retval = -EPERM; if (new_inode && (new_dir->i_mode & S_ISVTX) && current->fsuid != new_inode->i_uid && current->fsuid != new_dir->i_uid && !fsuser()) goto end_rename; if (S_ISDIR(old_inode->i_mode)) { retval = -EEXIST; if (new_bh) goto end_rename; if ((retval = permission(old_inode, MAY_WRITE)) != 0) goto end_rename; retval = -EINVAL; if (subdir(new_dir, old_inode)) goto end_rename; retval = -EIO; dir_bh = xiafs_bread(old_inode,0,0); if (!dir_bh) goto end_rename; if (PARENT_INO(dir_bh->b_data) != old_dir->i_ino) goto end_rename; retval = -EMLINK; if (new_dir->i_nlink > 64000) goto end_rename; } if (!new_bh) new_bh = xiafs_add_entry(new_dir, new_name, new_len, &new_de, &new_de_pre); retval = -ENOSPC; if (!new_bh) goto end_rename; /* sanity checking */ if ( (new_inode && (new_de->d_ino != new_inode->i_ino)) || (new_de->d_ino && !new_inode) || (old_de->d_ino != old_inode->i_ino)) { xiafs_rm_entry(new_de, new_de_pre); brelse(old_bh); brelse(new_bh); brelse(dir_bh); iput(old_inode); iput(new_inode); current->counter=0; schedule(); goto try_again; } xiafs_rm_entry(old_de, old_de_pre); new_de->d_ino = old_inode->i_ino; if (new_inode) { new_inode->i_nlink--; new_inode->i_dirt = 1; } mark_buffer_dirty(old_bh, 1); mark_buffer_dirty(new_bh, 1); if (dir_bh) { PARENT_INO(dir_bh->b_data) = new_dir->i_ino; mark_buffer_dirty(dir_bh, 1); old_dir->i_nlink--; new_dir->i_nlink++; old_dir->i_dirt = 1; new_dir->i_dirt = 1; } retval = 0; end_rename: brelse(dir_bh); brelse(old_bh); brelse(new_bh); iput(old_inode); iput(new_inode); iput(old_dir); iput(new_dir); return retval; }
int main(void) { return subdir(); }
int main(int argc, char *argv[]) { struct iovec *iov; int ch, iovlen; char source [MAXPATHLEN], target[MAXPATHLEN], errmsg[255]; char uid_str[20], gid_str[20]; char fstype[] = "unionfs"; char *p, *val; iov = NULL; iovlen = 0; memset(errmsg, 0, sizeof(errmsg)); while ((ch = getopt(argc, argv, "bo:")) != -1) { switch (ch) { case 'b': printf("\n -b is deprecated. Use \"-o below\" instead\n"); build_iovec(&iov, &iovlen, "below", NULL, 0); break; case 'o': p = strchr(optarg, '='); val = NULL; if (p != NULL) { *p = '\0'; val = p + 1; if (strcmp(optarg, "gid") == 0) { parse_gid(val, gid_str, sizeof(gid_str)); val = gid_str; } else if (strcmp(optarg, "uid") == 0) { parse_uid(val, uid_str, sizeof(uid_str)); val = uid_str; } } build_iovec(&iov, &iovlen, optarg, val, (size_t)-1); break; case '?': default: usage(); /* NOTREACHED */ } } argc -= optind; argv += optind; if (argc != 2) usage(); /* resolve both target and source with realpath(3) */ if (checkpath(argv[0], target) != 0) err(EX_USAGE, "%s", target); if (checkpath(argv[1], source) != 0) err(EX_USAGE, "%s", source); if (subdir(target, source) || subdir(source, target)) errx(EX_USAGE, "%s (%s) and %s (%s) are not distinct paths", argv[0], target, argv[1], source); build_iovec(&iov, &iovlen, "fstype", fstype, (size_t)-1); build_iovec(&iov, &iovlen, "fspath", source, (size_t)-1); build_iovec(&iov, &iovlen, "from", target, (size_t)-1); build_iovec(&iov, &iovlen, "errmsg", errmsg, sizeof(errmsg)); if (nmount(iov, iovlen, 0)) err(EX_OSERR, "%s: %s", source, errmsg); exit(0); }
bool SubdirsMetaMakefileGenerator::init() { if(init_flag) return false; init_flag = true; if(Option::recursive) { QString old_output_dir = QDir::cleanPath(Option::output_dir); if(!old_output_dir.endsWith('/')) old_output_dir += '/'; QString old_output = Option::output.fileName(); QString oldpwd = QDir::cleanPath(qmake_getpwd()); if(!oldpwd.endsWith('/')) oldpwd += '/'; const QStringList &subdirs = project->values("SUBDIRS"); static int recurseDepth = -1; ++recurseDepth; for(int i = 0; i < subdirs.size(); ++i) { Subdir *sub = new Subdir; sub->indent = recurseDepth; QFileInfo subdir(subdirs.at(i)); if(!project->isEmpty(subdirs.at(i) + ".file")) subdir = project->first(subdirs.at(i) + ".file"); else if(!project->isEmpty(subdirs.at(i) + ".subdir")) subdir = project->first(subdirs.at(i) + ".subdir"); QString sub_name; if(subdir.isDir()) subdir = QFileInfo(subdir.filePath() + "/" + subdir.fileName() + Option::pro_ext); else sub_name = subdir.baseName(); if(!subdir.isRelative()) { //we can try to make it relative QString subdir_path = subdir.filePath(); if(subdir_path.startsWith(oldpwd)) subdir = QFileInfo(subdir_path.mid(oldpwd.length())); } //handle sub project QMakeProject *sub_proj = new QMakeProject(project->properties()); for (int ind = 0; ind < sub->indent; ++ind) printf(" "); sub->input_dir = subdir.absolutePath(); if(subdir.isRelative() && old_output_dir != oldpwd) { sub->output_dir = old_output_dir + "/" + subdir.path(); printf("Reading %s [%s]\n", subdir.absoluteFilePath().toLatin1().constData(), sub->output_dir.toLatin1().constData()); } else { //what about shadow builds? sub->output_dir = sub->input_dir; printf("Reading %s\n", subdir.absoluteFilePath().toLatin1().constData()); } qmake_setpwd(sub->input_dir); Option::output_dir = sub->output_dir; if(Option::output_dir.at(Option::output_dir.length()-1) != QLatin1Char('/')) Option::output_dir += QLatin1Char('/'); sub_proj->read(subdir.fileName()); if(!sub_proj->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) { fprintf(stderr, "Project file(%s) not recursed because all requirements not met:\n\t%s\n", subdir.fileName().toLatin1().constData(), sub_proj->values("QMAKE_FAILED_REQUIREMENTS").join(" ").toLatin1().constData()); delete sub; delete sub_proj; continue; } sub->makefile = MetaMakefileGenerator::createMetaGenerator(sub_proj, sub_name); if(0 && sub->makefile->type() == SUBDIRSMETATYPE) { subs.append(sub); } else { const QString output_name = Option::output.fileName(); Option::output.setFileName(sub->output_file); sub->makefile->write(sub->output_dir); delete sub; qmakeClearCaches(); sub = 0; Option::output.setFileName(output_name); } Option::output_dir = old_output_dir; qmake_setpwd(oldpwd); } --recurseDepth; Option::output.setFileName(old_output); Option::output_dir = old_output_dir; qmake_setpwd(oldpwd); } Subdir *self = new Subdir; self->input_dir = qmake_getpwd(); self->output_dir = Option::output_dir; if(!Option::recursive || (!Option::output.fileName().endsWith(Option::dir_sep) && !QFileInfo(Option::output).isDir())) self->output_file = Option::output.fileName(); self->makefile = new BuildsMetaMakefileGenerator(project, name, false); self->makefile->init(); subs.append(self); return true; }