]> Creatis software - bbtk.git/blobdiff - packages/std/src/bbstdFilesFromDirectory.h
Box to return file names from a directory (recursive expl or not)
[bbtk.git] / packages / std / src / bbstdFilesFromDirectory.h
diff --git a/packages/std/src/bbstdFilesFromDirectory.h b/packages/std/src/bbstdFilesFromDirectory.h
new file mode 100644 (file)
index 0000000..10ec9b2
--- /dev/null
@@ -0,0 +1,54 @@
+#ifndef __bbstdFilesFromDirectory_h_INCLUDED__
+#define __bbstdFilesFromDirectory_h_INCLUDED__
+#include "bbtkAtomicBlackBox.h"
+#include "iostream"
+
+namespace bbstd
+{
+
+class /*BBTK_EXPORT*/ FilesFromDirectory
+ : 
+   public bbtk::AtomicBlackBox
+{
+  BBTK_BLACK_BOX_INTERFACE(FilesFromDirectory,bbtk::AtomicBlackBox);
+//==================================================================
+/// User callback called in the box contructor
+virtual void bbUserConstructor();
+/// User callback called in the box copy constructor
+virtual void bbUserCopyConstructor(bbtk::BlackBox::Pointer);
+/// User callback called in the box destructor
+virtual void bbUserDestructor();
+//==================================================================
+  BBTK_DECLARE_INPUT(In,std::string);
+  BBTK_DECLARE_INPUT(Recursive,bool);  
+  BBTK_DECLARE_OUTPUT(Out,std::vector<std::string>);
+  BBTK_PROCESS(Process);
+  void Process();
+  
+  private :
+  std::string NormalizePath(std::string const &pathname);
+  int Explore(std::string const &dirpath, bool recursive);
+  
+  /// List of file names
+  std::vector<std::string> Filenames;
+  /// name of the root directory to explore
+  std::string DirName;
+};
+
+//=================================================================
+// UserBlackBox description
+BBTK_BEGIN_DESCRIBE_BLACK_BOX(FilesFromDirectory,bbtk::AtomicBlackBox);
+BBTK_NAME("FilesFromDirectory");
+BBTK_AUTHOR("jpr@creatis.univ-lyon1.fr");
+BBTK_DESCRIPTION("returns the fullPathNames of the files in a Directory");
+BBTK_CATEGORY("");
+BBTK_INPUT(FilesFromDirectory,In,"Directory Name",std::string,"");
+BBTK_INPUT(FilesFromDirectory,Recursive,"Recursive directory exploration",bool,"");
+
+BBTK_OUTPUT(FilesFromDirectory,Out,"FullPathNames of the files",std::vector<std::string>,"");
+BBTK_END_DESCRIBE_BLACK_BOX(FilesFromDirectory);
+}
+// EO namespace bbstd
+
+#endif // __bbstdFilesFromDirectory_h_INCLUDED__
+