예제 #1
0
void rmDir(int DirBlock)
{
	directoryBlock dir;
	int dirStart, dirSize, y, z;
	readsector(DirBlock, (char*)&dir);
	if (DirBlock == 0)
	{
		return;
	}
	y = 0;
	while (y < DIRECTORYENTRYCOUNT)
	{
		if (dir.entries[y].fileType == IS_FILE)
		{
			dirStart = dir.entries[y].fileBlockStart;
			dirSize = dir.entries[y].fileBlockSize;
			z = dirStart;
			while( z < dirSize)
			{
				setFreeBlock(z);
				z++;
			}
			if (y == DIRECTORYENTRYCOUNT - 1)
				return;
		}
		else if (dir.entries[y].fileType == IS_DIRECTORY)
		{
			rmDir(dir.entries[y].fileBlockStart);
			setFreeBlock(y);
		}
		y++;
	}
}
예제 #2
0
BOOL FileUtils::rmDir(string dirName)
{
	char sTempFileFind[MAX_PATH] = "";
	sprintf_s(sTempFileFind, "%s\\*.*", dirName.c_str());
	
	CFileFind tempFind;
	BOOL isFinded = tempFind.FindFile(sTempFileFind);
	while (isFinded) {
		isFinded = tempFind.FindNextFile();
		/*
		 * 跳过 每个文件夹下面都有的两个特殊子文件夹:
		 *	(1) .  表示本文件夹自己
		 *	(2) .. 表示本文件夹的父文件夹
		 */
		if (!tempFind.IsDots()) {
			char tempFileOrDir[MAX_PATH] = "";
			sprintf_s(tempFileOrDir, "%s\\%s", dirName.c_str(), tempFind.GetFileName().GetBuffer(MAX_PATH));

			if (tempFind.IsReadOnly()) ::SetFileAttributes(tempFileOrDir, FILE_ATTRIBUTE_NORMAL);
			
			if (tempFind.IsDirectory()) rmDir(tempFileOrDir);
			else ::DeleteFile(tempFileOrDir);
		}
	}
	tempFind.Close();

	return ::RemoveDirectory(dirName.c_str());
}
예제 #3
0
//-  Constructor
clockTimer::clockTimer(Time& t, word fieldName, bool write)
:
    time_(t),
    fieldName_(fieldName),
    instTimeIndex_(0.0),
    timeIndex_(0.0),
    totalDuration_(0.0),
    duration_(0.0),
    instantDuration_(0.0),
    writeOut_(write),
    timePath_()
{
    if(writeOut_)
    {
        // directory: case/boundaries
        timePath_ = time_.path()/"timings";

        if(isDir(timePath_))
        {
            rmDir(timePath_);
        }

        if(Pstream::master())
        {
            mkDir(timePath_);
        }
    }



}
예제 #4
0
void rmDir(const char* path) {
  DIR* dir = opendir(path);
  if(!dir) {
    return;
  }
  struct dirent * dp;
  while((dp = readdir(dir)) != NULL) {
    const char* name = dp->d_name;
    if(strcmp(name, ".") == 0 || strcmp(name, "..") == 0) {
      continue;
    }
    char filePath[1024];
    if ((int) (sizeof(filePath)-1) < snprintf(filePath, sizeof(filePath), "%s/%s", path, name)) {
      continue; // buffer overflow
    }
    if(direxists(filePath)) {
      rmDir(filePath);
    }
    else {
      unlink(filePath);
    }
  }
  closedir(dir);
  rmdir(path);
}
예제 #5
0
bool Global::rmDir(const QString path, const bool onlyHidden, const bool onlyContent) {
    if (!QDir().exists(path))
        return true;

    bool success = true;

    // Remove content of dir
    QStringList list = QDir(path).entryList(QDir::AllEntries | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System, QDir::Name);

    foreach (const QString file, list) {
        if (onlyHidden && !file.trimmed().startsWith("."))
            continue;

        QFileInfo info(path + "/" + file);

        if (info.isDir()) {
            if (!rmDir(path + "/" + file), onlyHidden)
                success = false;
        }
        else {
            if (!QFile::remove(path + "/" + file))
                success = false;
        }
    }

    if (!onlyContent && !QDir().rmdir(path))
        return false;

    return success;
}
예제 #6
0
static void rmDir(const QString &path)
{
    QDir d(path);
    QStringList l = d.entryList(QDir::Dirs);
    QStringList::Iterator it;
    for (it = l.begin(); it != l.end(); ++it){
        if (((*it) == ".") || ((*it) == "..")) continue;
        QString p = path;
#ifdef WIN32
        p += "\\";
#else
        p += "/";
#endif
        p += *it;
        rmDir(p);
    }
    l = d.entryList();
    for (it = l.begin(); it != l.end(); ++it){
        if (((*it) == ".") || ((*it) == "..")) continue;
        QString p = path;
#ifdef WIN32
        p += "\\";
#else
        p += "/";
#endif
        p += *it;
        d.remove(p);
    }
    d.rmdir(path);
}
예제 #7
0
파일: xrm.c 프로젝트: mudchina/fy3
int main(object me, string file)
{
	seteuid(geteuid(me));
	write("rmdir 命令 v0.1  \nWrite By Lxh@Xxy\n"+
		"邮件:[email protected]\n");
    if (!file) return notify_fail("你要删除那个档案?\n");
	file=resolve_path(me->query("cwd"),file);
	log_file("cmds/xrm.log",
	sprintf("%s(%s) 删除 %s on %s\n",
	me->name(1),   //记录使用命令的人名
	geteuid(me),   //记录使用命令的ID
	file,          //记录删除的文件路径
	ctime(time()) ) ); //记录使用命令的时间
	flag=0;
	switch(file_size(file))
	{
		case -1:
			write("对不起,你无权删除这个目录(或文件)。\n");
			break;
		case -2:
			write("删除目录(文件)中...\n");
			if(rmDir(file)==0)
				write("删除失败。\n");
			else
				write("删除成功。\n");
			break;
		default:
			if(rm(file) )
				write("删除完成。\n");
			else
				write("你没有删除这个档案的权利。\n");
	}
	return 1;
}
예제 #8
0
/*!
  Implementation for traverse so always true.
*/
bool FileFixture::execute(void * objectInstance, QString actionName, QHash<QString, QString> parameters, QString & stdOut)
{
    Q_UNUSED(objectInstance);

    TasLogger::logger()->debug("> FileFixture::execute:" + actionName);

    if (actionName == "read_file") {
        readFile(parameters.value(FILE_NAME), stdOut);
    }else if (actionName == "read_file_part") {
        readFilePart(parameters.value(FILE_NAME),parameters.value(FILE_OFFSET).toInt(),parameters.value(DATA_LENGHT).toInt(), stdOut);
    } else if(actionName == "write_file") {
        writeFile(parameters.value(FILE_NAME), parameters.value(FILE_DATA), stdOut);
    } else if(actionName == "write_file_append") {
        writeFileAppend(parameters.value(FILE_NAME), parameters.value(FILE_DATA),parameters.value(FILE_OFFSET).toInt(),parameters.value(DATA_LENGHT).toInt(), stdOut);
    } else if(actionName == "delete_file") {
        deleteFile(parameters.value(FILE_NAME), stdOut);
    } else if(actionName == "mk_dir") {
        mkDir(parameters.value(FILE_NAME), stdOut);
    } else if(actionName == "rm_dir") {
        rmDir(parameters.value(FILE_NAME), stdOut);
    } else if(actionName == "list_files") {
        listFiles(parameters.value(FILE_PATH), parameters.value(FILE_NAME), stdOut);
    }

    return true;
}
예제 #9
0
void LoginDialog::realDeleteUin(int n)
{
    if (n) return;
    rmDir(QString::fromLocal8Bit(pMain->getFullPath("").c_str()));
    pClient->load(0);
    scanUIN();
    cmbUIN->clear();
    loadUins();
}
예제 #10
0
/*
 * name 是 开始菜单快捷方式直属目录的名字
 */
void FileUtils::deleteStartMenuShortcutDir(string dirName)
{
	char szShortcutDir[MAX_PATH] = "";
	
	// 取得要删除的快捷方式目录的全路径
	string startMenuProgramsPath = FileUtils::getStartMenuProgramsPath();
	sprintf_s(szShortcutDir, "%s\\%s", startMenuProgramsPath.c_str(), dirName.c_str());
	TRACE("%s\n", szShortcutDir);
	
	// 删除开始菜单快捷方式目录
	rmDir(szShortcutDir);
}
예제 #11
0
void LoginDialog::profileDelete()
{
    int n = cmbProfile->currentItem();
    if ((n < 0) || (n >= (int)(CorePlugin::m_plugin->m_profiles.size())))
        return;
    string curProfile = CorePlugin::m_plugin->m_profiles[n];
    CorePlugin::m_plugin->setProfile(curProfile.c_str());
    rmDir(QFile::decodeName(user_file("").c_str()));
    CorePlugin::m_plugin->setProfile(NULL);
    CorePlugin::m_plugin->changeProfile();
    CorePlugin::m_plugin->m_profiles.clear();
    CorePlugin::m_plugin->loadDir();
    clearInputs();
    btnDelete->setEnabled(false);
    fill();
}
예제 #12
0
bool NetEin::rmDir(const QString &dirPath)
{
    QDir dir(dirPath);
    if (!dir.exists())
        return true;
    foreach(const QFileInfo &info, dir.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot)) {
        if (info.isDir()) {
            if (!rmDir(info.filePath()))
                return false;
        } else {
            if (!dir.remove(info.fileName()))
                return false;
        }
    }
    QDir parentDir(QFileInfo(dirPath).path());
    return parentDir.rmdir(QFileInfo(dirPath).fileName());
}
예제 #13
0
bool Global::copyDir(const QString src, const QString dst, const bool hidden) {
    if (!QDir().exists(src))
        return false;

    if (QDir().exists(dst))
        rmDir(dst);

    if (!QDir().mkpath(dst))
        return false;

    // Keep same folder permission
    preserveDirectoryPermission(src, dst); // Error isn't critical


    bool success = true;

    // Copy content of dir
    QStringList list;

    if (hidden)
        list = QDir(src).entryList(QDir::AllEntries | QDir::NoDotAndDotDot | QDir::System | QDir::Hidden, QDir::Name);
    else
        list = QDir(src).entryList(QDir::AllEntries | QDir::NoDotAndDotDot | QDir::System, QDir::Name);


    foreach (const QString file, list) {
        QFileInfo info(src + "/" + file);

        if (info.isDir()) {
            if (!copyDir(src + "/" + file, dst + "/" + file, hidden))
                success = false;
        }
        else if (info.isSymLink()) {
            QString symlinkTarget = getSymlinkTarget(src + "/" + file);

            if (symlinkTarget.isEmpty() || !QFile::link(symlinkTarget, dst + "/" + file))
                success = false;
        }
        else {
            if (!QFile::copy(src + "/" + file, dst + "/" + file))
                success = false;
        }
    }
예제 #14
0
bool RmLocalDirMsgEx::processIncoming(struct sockaddr_in* fromAddr, Socket* sock,
   char* respBuf, size_t bufLen, HighResolutionStats* stats)
{
   #ifdef FHGFS_DEBUG
      const char* logContext = "RmLocalDirMsg incoming";

      std::string peer = fromAddr ? Socket::ipaddrToStr(&fromAddr->sin_addr) : sock->getPeername();
      LOG_DEBUG(logContext, 4, std::string("Received a RmLocalDirMsg from: ") + peer);
   #endif // FHGFS_DEBUG
   
   FhgfsOpsErr rmRes = rmDir();
   
   RmLocalDirRespMsg respMsg(rmRes);
   respMsg.serialize(respBuf, bufLen);
   sock->sendto(respBuf, respMsg.getMsgLength(), 0,
      (struct sockaddr*)fromAddr, sizeof(struct sockaddr_in) );

   return true;      
}
예제 #15
0
void createusr(char * name, char * password, char * group)
{
	int i, fd, length;
	user * usr;
	iNode * aux;
	aux = current;
	current = superblock->root;
	fd = do_open("usersfile", 777, 777);
	usr = malloc(sizeof(user) * 100);
	do_read(fd, (char *)usr, sizeof(user) * 100);
	for(i = 0; i < 100 && usr[i].usrID; i++)
		if(strcmp(usr[i].name, name))
		{
			printf("Error: User already exists.\n");
			return ;
		}
	if(i == 100)
	{
		printf("Error: Too many users created.\n");
		return ;
	}
	length = str_len(name);
	name[length - 1] = 0;
	memcpy(usr[i].name, name, length - 1);
	length = str_len(password);
	password[length - 1] = 0;
	memcpy(usr[i].password, password, length - 1);
	usr[i].usrID = ++usrID;
	if(strcmp(group, "admin"))
		usr[i].group = ADMIN;
	else
		usr[i].group = USR;
	do_close(fd);
	rmDir("usersfile");
	fd = do_creat("usersfile", 777);
	write(fd, (void *)usr, sizeof(user) * 100);
	do_close(fd);

	current = aux;

	//free(usr);
	return;	
}
예제 #16
0
void CheckGLCacheVersion(const char* baseDir)
{
  char cachePath[1024];
  if ((int) (sizeof(cachePath)-1) < snprintf(cachePath, sizeof(cachePath), "%s" GLQUAKE_RELPATH "/cacheversion", baseDir)) {
    return; // buffer overflow
  }
  bool validCache = false;
  {
    GLCacheVersion vernum = 0;
    FILE* f = fopen(cachePath, "rb");
    if (f) {
      if (1 == fread(&vernum, sizeof(vernum), 1, f)) {
        if (vernum == kCurrentCacheVersion) {
          validCache = true;
        }
      }
      fclose(f);
    }
  }

#ifdef FORCE_INVALIDATE_CACHE
  validCache = false;
#endif

  if(!validCache) {
    PMPLOG(("Invalidating glquake cache."));
    char cacheDirPath[1024];
    if ( (int)(sizeof(cacheDirPath)-1) < snprintf(cacheDirPath, sizeof(cacheDirPath), "%s" GLQUAKE_RELPATH, baseDir)) {
      return; // Ran out ot memory
    }
    rmDir(cacheDirPath);
    Sys_mkdir(cacheDirPath);
    FILE* f = fopen(cachePath, "wb");
    if (f) {
      GLCacheVersion vernum = kCurrentCacheVersion;
      fwrite(&vernum, sizeof(vernum), 1, f);
      fclose(f);
    } else {
        PMPLOG(("Could not write %s %d.\n", cachePath, errno));
    }
  }
}
예제 #17
0
파일: Util.cpp 프로젝트: absorbguo/Paddle
void rmDir(const char* folderName) {
  if (isDir(folderName)) {
    DIR* dp;
    struct dirent* ep;
    std::string buf;
    dp = opendir(folderName);
    while ((ep = readdir(dp)) != NULL) {
      if (strcmp(ep->d_name, ".") && strcmp(ep->d_name, "..")) {
        buf = std::string(folderName) + "/" + std::string(ep->d_name);
        if (isDir(buf.c_str())) {
          rmDir(buf.c_str());
        } else {
          remove(buf.c_str());
        }
      }
    }
    closedir(dp);
    rmdir(folderName);
  }
}
예제 #18
0
파일: xrm.c 프로젝트: mudchina/fy3
int rmDir(string file)
{
	string tmp;
	if(flag>15)
		return 0;
	reset_eval_cost();
	switch(file_size(file))
	{
		case -1 : 
			flag=16;//设置出错中断
			write("部分文件无权删除,错误!\n");
			return 0;
			break;
		case -2 :
			//删除此目录下的文件和目录
			if(file[sizeof(file)]!='/')
				file=file+"/";
			foreach(tmp in get_dir(file))
			{
				if(!rmDir(file+tmp))
				{
					flag=16;//中断,因为删除出错
					return 0;
				}
			}
			if(!rmdir(file))
			{
				flag=16;//中断,因为删除出错
				return 0;
			}
			break;
		default :
			if(!rm(file))
			{
				flag=16;//中断,因为删除出错
				return 0;
			}
			break;
	}
	return 1;
}
예제 #19
0
void rm(char * path)
{
	int y, z, dirStart, dirSize,blockEntryToRemove,blockToRemove;
	directoryBlock erasedBlock;
	char *destinyBlock,*dirRm;
	destinyBlock = getPathName(path, 1);
	dirRm  = getPathName(path, 2); 
	blockToRemove = findFileBlockInPath(destinyBlock);
	readsector(blockToRemove, (char*)&erasedBlock);
	blockEntryToRemove = findFileInDirectory(erasedBlock, dirRm);
	if (blockEntryToRemove == -1)
	{
		printstring("Directory does not exist\n");
		return;
	}
	if (erasedBlock.entries[blockEntryToRemove].fileType == IS_FILE)
	{
		dirStart = erasedBlock.entries[blockEntryToRemove].fileBlockStart;
		dirSize = erasedBlock.entries[blockEntryToRemove].fileBlockSize;
		z = dirStart;
		while (z < dirSize)
		{
			setFreeBlock(z);
			z++;
		}
	}
	else if (erasedBlock.entries[blockEntryToRemove].fileType == IS_DIRECTORY)
	{
		rmDir(erasedBlock.entries[blockEntryToRemove].fileBlockStart);
		setFreeBlock(erasedBlock.entries[blockEntryToRemove].fileBlockStart);
	}
	y = 0;
	while (y < sizeof(erasedBlock.entries[blockEntryToRemove].fileName))
	{
		erasedBlock.entries[blockEntryToRemove].fileName[y] = '\0';
	}
	erasedBlock.entries[blockEntryToRemove].fileBlockSize = 0;
	erasedBlock.entries[blockEntryToRemove].fileBlockStart = 0;
	writesector(blockToRemove, (char*)&erasedBlock);
}
예제 #20
0
void OS2Factory::rmDir( const string &rPath )
{
    struct dirent *file;
    DIR *dir;

    dir = opendir( rPath.c_str() );
    if( !dir ) return;

    // Parse the directory and remove everything it contains
    while( (file = readdir( dir )) )
    {
        struct stat statbuf;
        string filename = file->d_name;

        // Skip "." and ".."
        if( filename == "." || filename == ".." )
        {
            continue;
        }

        filename = rPath + "\\" + filename;

        if( !stat( filename.c_str(), &statbuf ) && statbuf.st_mode & S_IFDIR )
        {
            rmDir( filename );
        }
        else
        {
            unlink( filename.c_str() );
        }
    }

    // Close the directory
    closedir( dir );

    // And delete it
    rmdir( rPath.c_str() );
}
예제 #21
0
NetEin::NetEin(QWidget *parent)
{
QString homepath = QDir::homePath(); 
int i = 0;
setupUi(this);
connect( pushButton_net, SIGNAL( clicked() ), this, SLOT(listWidget_show()));
connect( pushButton_go, SIGNAL( clicked() ), this, SLOT(go()));
connect( pushButton_end, SIGNAL( clicked() ), this, SLOT(end()));
connect( chk_password, SIGNAL( clicked() ), this, SLOT(Kennwort()));
// Vorsichtshalver ./qt4-fs-client löschen und neu anlegen, da eventuell nicht leer
       rmDir(homepath + "/.qt5-fs-client");
       QString befehl = "mkdir " + homepath + "/.qt5-fs-client 2>/dev/null" ;
       system (befehl.toLatin1().data());
// Ini-Datei auslesen
   QFile file(homepath + "/.config/qt5-fsarchiver/qt5-fsarchiver.conf");
   if (file.exists()) {
        QSettings setting("qt5-fsarchiver", "qt5-fsarchiver");
        setting.beginGroup("Basiseinstellungen");
        int auswertung = setting.value("Passwort").toInt();
        if (auswertung ==1){
           	txt_key ->setEchoMode(QLineEdit::Normal);
                chk_password->setChecked(Qt::Checked);
        } 
   	else
		txt_key ->setEchoMode(QLineEdit::Password);
        auswertung = setting.value("save").toInt();
        if (auswertung ==1)
           chk_datesave->setChecked(Qt::Checked);      
        setting.endGroup();
   }
    while (widget_net[i] != ""){
    	listWidget_net->addItem (widget_net[i]);
        i++;
        if (i > 99)
            break;   
        }
}
예제 #22
0
/*------------------------------------------------------------------------
 * lfsControl - Provide control functions for a local file system 
 *------------------------------------------------------------------------
 */
devcall	lfsControl (
	 struct dentry	*devptr,	
	 int32	func,			/* a control function		*/
	 int32	arg1,			/* argument #1			*/
	 int32	arg2			/* argument #2			*/
	)
{
	int retval;
	switch(func)
	{
		case LF_CTL_FORMAT:
			{
				retval=	lfscreate(LF_DISK_DEV,arg1,arg2);							
				return retval;
			}
		case LF_CTL_MKDIR:
			{
				retval = mkDir((char*)arg1);
				return retval;
			}
		case LF_CTL_RMDIR:
			{
				retval = rmDir((char*)arg1);
				return retval;
			}
		case LF_CTL_DEL:
			{
				retval = rmFile((char*)arg1);
				return retval;
			}
		default:
			return SYSERR;
	}
	return OK;	

}
예제 #23
0
void Win32Factory::rmDir( const string &rPath )
{
    WIN32_FIND_DATA find;
    string file;
    string findFiles = rPath + "\\*";
    HANDLE handle    = FindFirstFile( findFiles.c_str(), &find );

    while( handle != INVALID_HANDLE_VALUE )
    {
        // If file is neither "." nor ".."
        if( strcmp( find.cFileName, "." ) && strcmp( find.cFileName, ".." ) )
        {
            // Set file name
            file = rPath + "\\" + (string)find.cFileName;

            // If file is a directory, delete it recursively
            if( find.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
            {
                rmDir( file );
            }
            // Else, it is a file so simply delete it
            else
            {
                DeleteFile( file.c_str() );
            }
        }

        // If no more file in directory, exit while
        if( !FindNextFile( handle, &find ) )
            break;
    }

    // Now directory is empty so can be removed
    FindClose( handle );
    RemoveDirectory( rPath.c_str() );
}
예제 #24
0
// Remove a dirctory and its contents
bool Foam::rmDir(const fileName& directory)
{
    if (POSIX::debug)
    {
        Info<< "rmDir(const fileName&) : "
            << "removing directory " << directory << endl;
    }

    // Pointers to the directory entries
    DIR *source;
    struct dirent *list;

    // Attempt to open directory and set the structure pointer
    if ((source = opendir(directory.c_str())) == NULL)
    {
        WarningIn("rmDir(const fileName&)")
            << "cannot open directory " << directory << endl;

        return false;
    }
    else
    {
        // Read and parse all the entries in the directory
        while ((list = readdir(source)) != NULL)
        {
            fileName fName(list->d_name);

            if (fName != "." && fName != "..")
            {
                fileName path = directory/fName;

                if (path.type() == fileName::DIRECTORY)
                {
                    if (!rmDir(path))
                    {
                        WarningIn("rmDir(const fileName&)")
                            << "failed to remove directory " << fName
                            << " while removing directory " << directory
                            << endl;

                        closedir(source);

                        return false;
                    }
                }
                else
                {
                    if (!rm(path))
                    {
                        WarningIn("rmDir(const fileName&)")
                            << "failed to remove file " << fName
                            << " while removing directory " << directory
                            << endl;

                        closedir(source);

                        return false;
                    }
                }
            }

        }

        if (!rm(directory))
        {
            WarningIn("rmDir(const fileName&)")
                << "failed to remove directory " << directory << endl;

            closedir(source);

            return false;
        }

        closedir(source);

        return true;
    }
}
// Remove a dirctory and it's contents
bool rmDir(const fileName& directory)
{
    if (MSwindows::debug)
    {
        Info<< "rmdir(const fileName&) : "
            << "removing directory " << directory << endl;
    }

    bool success = true;

    // Need to destroy DirectorIterator prior to
    // removing directory otherwise fails on Windows XP
    {
        MSwindows::DirectoryIterator dirIt(directory);

        while (success && dirIt.hasNext())
        {
            const fileName & fName = dirIt.next();

            if (fName != "." && fName != "..")
            {
                fileName path = directory/fName;

                if (path.type() == fileName::DIRECTORY)
                {
                    success = rmDir(path);

                    if (!success)
                    {
                        WarningIn("rmdir(const fileName&)")
                                << "failed to remove directory " << fName
                                << " while removing directory " << directory
                                << endl;
                    }
                }
                else
                {
                    success = rm(path);

                    if (!success)
                    {
                        WarningIn("rmdir(const fileName&)")
                                << "failed to remove file " << fName
                                << " while removing directory " << directory
                                << endl;
                    }
                }
            }
        }
    }

    if (success)
    {
        success = ::RemoveDirectory(directory.c_str());

        if (!success)
        {
            WarningIn("rmdir(const fileName&)")
                    << "failed to remove directory " << directory << endl;
        }
    }

    return success;
}
void Foam::multiSolver::setInitialSolverDomain(const word& solverDomainName)
{

    if (!solverDomains_.found(solverDomainName))
    {
        FatalErrorIn("multiSolver::setInitialSolverDomain")
            << "Initial solverDomainName '" << solverDomainName << "' does"
            << " not exist in multiSolver dictionary.  Found entries are: "
            << solverDomains_.toc()
            << abort(FatalError);
    }

    currentSolverDomain_ = solverDomainName;

    setSolverDomainControls(currentSolverDomain_);

    // Purge all time directories from case directory root
    purgeTimeDirs(multiDictRegistry_.path());
    
    // Purge any constant/superLoopData/
    fileName superLoopDataPath
    (
        multiDictRegistry_.path()/multiDictRegistry_.constant()
            /"superLoopData"
    );
    if (exists(superLoopDataPath))
    {
        rmDir(superLoopDataPath);
    }

    // Read initial settings and determine data source (from which path the
    // initial data is copied, the starting superLoop_, and the current
    // globalTime (used to determine globalOffset).  Rules that are applied:
    //
    //   1. superLoop_ = data source superLoop
    //       a. unless data source solverDomain != currentSolverDomain_, in
    //          which case, superLoop_ = data source superLoop + 1
    //   2. globalTime = data source globalTime.  globalTime does not increment
    //      when swapping solver domains.
    //   3. startTime = data source local time
    //       a. unless data source solverDomain != currentSolverDomain_, in
    //          which case, startTime is dictated by the solverDomains
    //          subdictionary.
    //   4. endTime is determined by the solverDomains subdictionary
    //       a. unless the finalStopAt trumps it

    // Find initial data source
    timeCluster tcSource(initialDataSource());

    fileName sourcePath(findInstancePath(tcSource, tcSource.size() - 1));
    superLoop_ = tcSource.superLoop();
    globalIndex_ = tcSource.globalIndex();
    
    // If starting from initial conditions, superLoop_ = -1
    if (superLoop_ < 0) superLoop_ = 0;
    scalar globalTime(tcSource.globalValue(tcSource.size() - 1));
    scalar localStartTime(tcSource.localValue(tcSource.size() -1));

    // Now to apply the exceptions if currentSolverDomain_ != data source
    // solverDomain (see long comment above).
    if (sourcePath.path().path().name() != currentSolverDomain_)
    {
        superLoop_++;
        globalIndex_++;
        
        switch (startFrom_)
        {
            case mtsFirstTime:
                localStartTime = 0;
                break;
            case mtsStartTime:
                localStartTime = startTime_;
                break;
            case mtsLatestTimeThisDomain:
                {
                    timeCluster tcTemp
                    (
                        findLatestLocalTime
                        (
                            readSolverDomainTimes(currentSolverDomain_)
                        )
                    );
                    localStartTime = tcTemp.localValue(0);
                }
                break;
            case mtsLatestTimeAllDomains:
                localStartTime = globalTime;
                break;
        }
    }

    startTime_ = localStartTime;

    globalTimeOffset_ = globalTime - startTime_;
    
    // Give multiDictRegistry a time value (required for regIOobject::write()
    // to case/[timeValue]
    multiDictRegistry_.setTime(startTime_, 0);

    // Copy the source data and any previous time directories to
    // case/[localTime]
    forAll(tcSource, i)
    {
        fileName copyMe(findInstancePath(tcSource, i));
        cp(copyMe, multiDictRegistry_.path());
    }
예제 #27
0
void int_79(size_t call, size_t param){
	switch(call){
	case CREATE:/* create function */
		CreateProcessAt_in_kernel((createProcessParam *)param);
		break;
	case KILL: /* kill function */
		kill_in_kernel(param);/*param == pid*/
		break;
	case BLOCK:/* block function */
		block_process_in_kernel(param);/*param == pid*/
		break;
	case CLEAR_TERM:
		clearTerminalBuffer_in_kernel(param); /*param == ttyid*/
		break;
	case WAIT_PID:
		waitpid_in_kernel(param); /*param == pid*/
		break;
	case TERM_SIZE:
		getTerminalSize_in_kernel((int *)param); /*param == *size*/
		break;
	case TERM_CURPOS:
		getTerminalCurPos_in_kernel((int *)param); /*param == *curpos*/
		break;
	case CURR_TTY:
		getCurrentTTY_in_kernel((int *)param); /*param == *currtty*/
		break;
	case MK_FIFO:
		mkfifo_in_kernel((fifoStruct *)param);
		break;
	case SEM_GET:
		semget_in_kernel((semItem *)param);
		break;
	case SEM_UP:
		up_in_kernel(param); /*param == key*/
		break;
	case SEM_DOWN:
		down_in_kernel(param);/*param == key*/
		break;
	case MK_DIR:
		makeDir((char *)param);/*param == nameDIR*/
		break;
	case LS_COM:
		ls_in_kernel((char *)param);/*param == path*/
		break;
	case RM_COM:
		rmDir((char *)param);/*param == path*/
		break;
	case TOUCH_COM:
		touch_in_kernel((char *)param);/*param == filename*/
		break;
	case CAT_COM:
		cat_in_kernel((char *)param);/*param == filename*/
		break;
	case CD_COM:
		cd_in_kernel((char *)param);/*param == path*/
		break;
	case CREAT_COM:
		creat_in_kernel((creat_param *)param);
		break;
	case RM_FIFO:
		rmfifo_in_kernel((fifoStruct *)param);
		break;
	case SEM_RM:
		semrm_in_kernel(param);
		break;
	}

}
예제 #28
0
void rmfifo_in_kernel(fifoStruct * param){
	rmDir("fifoa");
	rmDir("fifob");
	delete_fifo_fd(param->fd1);
	delete_fifo_fd(param->fd2);
}
예제 #29
0
void mv(char * filename, char * path)
{
	int i, name_length, type;
	filename[str_len(filename) - 1] = 0;
	iNode * path_inode = current;
	path_inode = parser_path(path, path_inode);
	iNode * filename_inode = current;
	filename_inode = parser_path(filename, filename_inode);

	if(filename_inode->gid < currentUsr.group)
	{
		printf("\nCan not move '%s'. Permission denied.", filename);
		return ;
	}

	if(filename_inode == NULL)
	{
		printf("\nCan not move '%s'. File doesn't exist.", filename);
		return ;
	}

	if(path_inode == NULL)
	{
		name_length = str_len(path);
		for(i = 0; i < name_length; i++)
			if(path[i] == '/')
			{
				printf("\nCan not move '%s' to '%s'. Directory doesn't exist.", filename, path);
				return;
			}
		rename_file(filename_inode->iNode_number, path);
		return ;
	}

	int init_block = current->data.direct_blocks[0];
	directoryEntry * dr = (directoryEntry*)calloc(64 * 96, 1);
	read_disk(0, init_block, dr, (BLOCK_SIZE * 12), 0);
	for(i = 1; i < 96; i++){
		if( strcmp(filename, dr[i].name) == 1){
			type = dr[i].type;
			break;
		}
	}

	if(type == DIRECTORY)
	{
		insert_directory_entry(filename_inode, path_inode, filename);

		int inode_number = filename_inode->iNode_number;
		init_block = current->data.direct_blocks[0];
		directoryEntry * dr = (directoryEntry*)calloc(sizeof(directoryEntry),96);
		read_disk(0,init_block,dr,BLOCK_SIZE*12,0);
		iNode * parent = fs_get_inode(dr[1].inode);
		int father_init_block = current->data.direct_blocks[0];
		directoryEntry * father_dr = (directoryEntry*)calloc(sizeof(directoryEntry),96);
		read_disk(0,father_init_block,father_dr,BLOCK_SIZE*12,0);

		for ( i = 2; i < 96; i++){
			if ( father_dr[i].inode == inode_number){
				dr[i].type = 0;
				dr[i].inode = 0;
				dr[i].lenght = 0;
				strcopy(dr[i].name,"\0",1 );
				break;
			}
		}
		write_disk(0,init_block,dr,BLOCK_SIZE*12,0);
	}
	else if( type == FILE)
	{
		insert_file(filename, 777, path_inode);
		rmDir(filename);
	}

	return ;
}