예제 #1
0
파일: dir.c 프로젝트: tcliuyong/C-CPP
int main()
{
	deldir();
	//puts("scan liuyong");
	//scan_dir("/home/liuyong",0);
	//puts("ok");
	return 0;
}
예제 #2
0
파일: ARVORE.C 프로젝트: h3nnn4n/main_ccs
//******************************************************************
void deleta_no(pont &inicio)  //versao nao recursiva
{pont pai, filho; pai = filho = inicio;
 int number;
 clrscr();
 printf("Qual valor deletar? ");
 scanf ("%d", &number);


 int chave = 1;
 if (!inicio)    //mesma coisa que: if (inicio == 0)
   {printf("Arvore Vazia");
   }
 else
   {if (pai->valor == number)   //deletar o inicio da arvore
      {if ( (pai->esq != 0) && (pai->dir != 0) )
	  {pai = pai->esq;
	   while (pai->dir != 0)
	     {pai = pai->dir;
	     }
	   pai->dir = filho->dir;
	   free(filho); inicio = pai;
	  }
	else if (pai->esq != 0)
	  {inicio = pai->esq;
	   free(pai);
	  }
	else if (pai->dir != 0)
	  {inicio = pai->dir;
	   free(pai);
	  }
	else  //arvore c/so um elemento
	  {inicio = 0;
	   free(pai);
	  }
      }
   else
      {while (chave)
	{pai = filho;
	 if (number > pai->valor)
	    {filho = pai->dir;
	     if (!filho)  //nao encontrado valor
	       chave = 0;
	     else if (filho->valor == number)
	       {chave = 0; deldir(pai, filho);
	       }
	     }
	 else
	     {filho = pai->esq;
	      if (!filho)  //nao existe o valor procurado
		 chave = 0;
	      else if (filho->valor == number)
		 {chave = 0; delesq(pai, filho);
		 }
	      }
	}//fim while
      }
    }
}// fim
예제 #3
0
파일: mtnfs.c 프로젝트: kizkoh/mtnd
MTNSTAT *get_dircache(const char *path, int flag)
{
  MTNFS *mtnfs;
  MTNDIR   *md;
  MTNSTAT  *st;
  struct timeval tv;

  mtnfs = MTNFS_CONTEXT;
  pthread_mutex_lock(&(mtnfs->cache_mutex));
  gettimeofday(&tv, NULL);
  md = mtnfs->dircache;
  while(md){
    if((tv.tv_sec - md->tv.tv_sec) > 10){
      clrstat(md->st);
      md->st   = NULL;
      md->flag = 0;
    }
    if((tv.tv_sec - md->tv.tv_sec) > 60){
      if(md == mtnfs->dircache){
        md = (mtnfs->dircache = deldir(mtnfs->dircache));
      }else{
        md = deldir(md);
      }
      continue;
    }
    if(strcmp(md->path, path) == 0){
      break;
    }
    md = md->next;
  }
  if(md == NULL){
    md = newdir(path);
    if((md->next = mtnfs->dircache)){
      mtnfs->dircache->prev = md;
    }
    mtnfs->dircache = md;
  }
  st = (!flag || md->flag) ? cpstat(md->st) : NULL;
  pthread_mutex_unlock(&(mtnfs->cache_mutex));
  return(st);
}
예제 #4
0
파일: lineed.c 프로젝트: hlyytine/daydream
int fileattach(void)
{
	char olddir[1024];
	char fabuf[1024];
	FILE *falist;
	int cnt = 0;
	struct dirent *dent;
	DIR *dh;

	if (cleantemp() == -1) {
		DDPut(sd[tempcleanerrstr]);
		return 0;
	}
	recfiles(currnode->MULTI_TEMPORARY, 0);

	snprintf(fabuf, sizeof fabuf, "%s/attachs.%d", DDTMP, node);
	/* FIXME: check falist == NULL */
	falist = fopen(fabuf, "w");

	if ((dh = opendir(currnode->MULTI_TEMPORARY))) {
		getcwd(olddir, 1024);
		chdir(currnode->MULTI_TEMPORARY);
		while ((dent = readdir(dh))) {
			if (dent->d_name[0] == '.' && (dent->d_name[1] == '\0' || (dent->d_name[1] == '.' && dent->d_name[2] == '\0')))
				continue;
			if (!strcmp(".packtmp", dent->d_name))
				continue;

			deldir(".packtmp");
			ddprintf(sd[afqstr], dent->d_name);
			if (HotKey(HOT_YESNO) == 1) {
				fprintf(falist, "%s\n", dent->d_name);
				cnt++;
			} else {
				unlink(dent->d_name);
			}
			if (!checkcarrier())
				break;
		}
		chdir(olddir);
		closedir(dh);
	}
	fclose(falist);
	if (!cnt) {
		snprintf(fabuf, sizeof fabuf, "%s/attachs.%d", DDTMP, node);
		unlink(fabuf);
	}
	return 1;
}