コード例 #1
0
ファイル: fat_sync.cpp プロジェクト: AnnikaH/IncludeOS
  Dirent FAT::stat(Path path, const Dirent* const start) const
  {
    if (UNLIKELY(path.empty())) {
      return Dirent(this, Enttype::DIR, "/", 0);
    }

    FS_PRINT("stat_sync: %s\n", path.back().c_str());
    // extract file we are looking for
    const std::string filename = path.back();
    path.pop_back();

    // result directory entries are put into @dirents
    dirvector dirents;

    auto err = traverse(path, dirents, start);
    if (UNLIKELY(err))
      return Dirent(this, INVALID_ENTITY); // for now

    // find the matching filename in directory
    for (auto& e : dirents)
    if (UNLIKELY(e.name() == filename)) {
      // return this directory entry
      return e;
    }
    // entry not found
    return Dirent(this, INVALID_ENTITY);
  }
コード例 #2
0
ファイル: fat.cpp プロジェクト: fwsGonzo/fs_fat
 void FAT::stat(const std::string& strpath, on_stat_func callback)
 {
   auto path = std::make_shared<Path> (strpath);
   if (unlikely(path->empty()))
   {
     // root doesn't have any stat anyways (except ATTR_VOLUME_ID in FAT)
     callback(true, Dirent(INVALID_ENTITY, strpath));
     return;
   }
   
   debug("stat: %s\n", path->back().c_str());
   // extract file we are looking for
   std::string filename = path->back();
   path->pop_back();
   
   traverse(path,
   [this, filename, &callback] (error_t error, dirvec_t dirents)
   {
     if (unlikely(error))
     {
       // no path, no file!
       callback(error, Dirent(INVALID_ENTITY, filename));
       return;
     }
     
     // find the matching filename in directory
     for (auto& e : *dirents)
     {
       if (unlikely(e.name() == filename))
       {
         // read this file
         callback(no_error, e);
         return;
       }
     }
     
     // not found
     callback(true, Dirent(INVALID_ENTITY, filename));
   });
 }
コード例 #3
0
ファイル: fat_async.cpp プロジェクト: AnnikaH/IncludeOS
  void FAT::stat(Path_ptr path, on_stat_func func, const Dirent* const start) const
  {
    // manual lookup
    if (UNLIKELY(path->empty())) {
      // Note: could use ATTR_VOLUME_ID in FAT
      func(no_error, Dirent(this, DIR, "/", 0));
      return;
    }

    FS_PRINT("stat: %s\n", path->back().c_str());
    // extract file we are looking for
    std::string filename = path->back();
    path->pop_back();

    traverse(
      path,
      cluster_func::make_packed(
      [this, filename, func] (error_t error, Dirvec_ptr dirents)
      {
        if (UNLIKELY(error)) {
          // no path, no file!
          func(error, Dirent(this, INVALID_ENTITY, filename));
          return;
        }

        // find the matching filename in directory
        for (auto& e : *dirents) {
          if (UNLIKELY(e.name() == filename)) {
            // return this dir entry
            func(no_error, e);
            return;
          }
        }

        // not found
        func({ error_t::E_NOENT, filename }, Dirent(this, INVALID_ENTITY, filename));
      }),
      start
    );
  }
コード例 #4
0
ファイル: fat_async.cpp プロジェクト: andreashappe/IncludeOS
  void FAT::stat(const std::string& strpath, on_stat_func func)
  {
    // manual lookup
    auto path = std::make_shared<Path> (strpath);
    if (unlikely(path->empty())) {
      // root doesn't have any stat anyways
      // Note: could use ATTR_VOLUME_ID in FAT
      func({ error_t::E_NOENT, "Cannot stat root" }, Dirent(INVALID_ENTITY, strpath));
      return;
    }

    debug("stat: %s\n", path->back().c_str());
    // extract file we are looking for
    std::string filename = path->back();
    path->pop_back();

    traverse(path,
    [this, filename, func] (error_t error, dirvec_t dirents)
    {
      if (unlikely(error)) {
        // no path, no file!
        func(error, Dirent(INVALID_ENTITY, filename));
        return;
      }

      // find the matching filename in directory
      for (auto& e : *dirents) {
        if (unlikely(e.name() == filename)) {
          // return this dir entry
          func(no_error, e);
          return;
        }
      }

      // not found
      func({ error_t::E_NOENT, filename }, Dirent(INVALID_ENTITY, filename));
    });
  }
コード例 #5
0
ファイル: ext4.cpp プロジェクト: RamanGupta16/IncludeOS
 void EXT4::stat(const std::string& strpath, on_stat_func callback)
 {
   (void) strpath;
   callback({ error_t::E_NOENT, "Not implemented" }, Dirent());
 }
コード例 #6
0
int Directory::fill(CPCHAR fileSpec)
{
	MStackCall(__FILE__,__LINE__);

	if (dirName != "")
		{
		HDIR		hdir = HDIR_CREATE;
		ULONG		count = 1000;
		char*		buf = new char[BUF_SIZE];
		int			attrib = 	FILE_READONLY |
			 					FILE_HIDDEN |
								FILE_SYSTEM |
								FILE_DIRECTORY |
								FILE_ARCHIVED;
		Array<RegExp>	r;

		FileExp2RegExpArray(fileSpec, r);

		if (DosFindFirst((PSZ)(const char*)mergePath(dirName, "*"), &hdir, attrib, buf,
			BUF_SIZE, &count, FIL_STANDARD) == NO_ERROR)
			{
			do
				{
				MTrace(("%s, %i matching entries", (const char*)mergePath(dirName, "*"), count));
				FILEFINDBUF3*	pffb = (FILEFINDBUF3*)buf;
				entry.SetDynamic(TRUE);

				// fake . & .. entries in / dir under MS-DOS / FAT file systems

				if (strcmp(pffb->achName, ".") != 0)
					{
					if (match(".", r))
						entry[entry.Size()] = Dirent(this, ".", pffb->fdateLastWrite,
																pffb->ftimeLastWrite,
																0,
																FILE_READONLY | FILE_DIRECTORY);
					if (match("..", r))
						entry[entry.Size()] = Dirent(this, "..", pffb->fdateLastWrite,
																pffb->ftimeLastWrite,
																0,
																FILE_READONLY | FILE_DIRECTORY);			}

				do
					{
					if (match(pffb->achName, r))
						{
						Dirent aDirent(this, pffb->achName, pffb->fdateLastWrite,
											pffb->ftimeLastWrite, pffb->cbFile, pffb->attrFile);
						int size = entry.Size();

						entry[size] = aDirent;
						}

					if (pffb->oNextEntryOffset)
						pffb = (FILEFINDBUF3*)(((char*)pffb) + pffb->oNextEntryOffset);
					else
						pffb = 0;
					}
				while (pffb);
				}
			while (DosFindNext(hdir, buf, BUF_SIZE, &count) == NO_ERROR);

			DosFindClose(hdir);
			entry.SetDynamic(FALSE);
			}

		delete buf;
		}

	return entry.Size();
}
コード例 #7
0
ファイル: ext4.cpp プロジェクト: doniexun/IncludeOS
 void EXT4::stat(const std::string& strpath, on_stat_func callback)
 {
   (void) strpath;
   callback(true, Dirent());
 }