tensorflow_io_gcs_filesystem/core/gcs_filesystem.cc
// Checks that the directory is empty (i.e no objects with this prefix exist).
// Deletes the GCS directory marker if it exists.
Checks that the directory is empty .
Deletes the GCS directory marker if it exists.
Checks that the directory is empty . Deletes the GCS directory marker if it exists .
void DeleteDir(const TF_Filesystem* filesystem, const char* path,
               TF_Status* status) {
  auto gcs_file =
      static_cast<GCSFileSystem*>(filesystem->plugin_filesystem)->Load(status);
  if (TF_GetCode(status) != TF_OK) {
    return;
  }
  auto childrens = GetChildrenBounded(gcs_file, path, 2, true, true, status);
  if (TF_GetCode(status) != TF_OK) return;
  if (childrens.size() > 1 || (childrens.size() == 1 && !childrens[0].empty()))
    return TF_SetStatus(status, TF_FAILED_PRECONDITION,
                        "Cannot delete a non-empty directory.");
  if (childrens.size() == 1 && childrens[0].empty()) {
    std::string dir = path;
    MaybeAppendSlash(&dir);
    DeleteFile(filesystem, dir.c_str(), status);
    return;
  }
  TF_SetStatus(status, TF_OK, "");
}
void DeleteDir ( const TF_Filesystem * filesystem , const char * path , TF_Status * status ) { auto gcs_file = static_cast < GCSFileSystem * > ( filesystem -> plugin_filesystem ) -> Load ( status ) ; if ( TF_GetCode ( status ) != TF_OK ) { return ; } auto childrens = GetChildrenBounded ( gcs_file , path , 2 , true , true , status ) ; if ( TF_GetCode ( status ) != TF_OK ) return ; if ( childrens . size ( ) > 1 || ( childrens . size ( ) == 1 && ! childrens [ 0 ] . empty ( ) ) ) return TF_SetStatus ( status , TF_FAILED_PRECONDITION , " " ) ; if ( childrens . size ( ) == 1 && childrens [ 0 ] . empty ( ) ) { std :: string dir = path ; MaybeAppendSlash ( & dir ) ; DeleteFile ( filesystem , dir . c_str ( ) , status ) ; return ; } TF_SetStatus ( status , TF_OK , " " ) ; }
Checks that the directory is empty (i.e no objects with this prefix exist).
Checks that the directory is empty ( i . e no objects with this prefix exist ) .
// A directory is considered empty either if there are no matching objects // with the corresponding name prefix or if there is exactly one matching // object and it is the directory marker. Therefore we need to retrieve // at most two children for the prefix to detect if a directory is empty. // This is the directory marker object. Delete it.