Intel® Integrated Performance Primitives
Community support and discussions relating to developing high-performance vision, signal, security, and storage applications.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!

how to use directory functions

Otto_Wesso
Beginner
128 Views
Hi,
i'm trying do build my own application with the IPP and now i need to access a directory. Sadly the documentation of the IPP brings no help. Can somebody give me a sample how to use the vm_dir_open() and the vm_dir_read() functions please?

Thanks and regards,
Otto
0 Kudos
2 Replies
Alexander_Modenov__I
New Contributor I
128 Views
Quoting - Otto Wesso
Hi,
i'm trying do build my own application with the IPP and now i need to access a directory. Sadly the documentation of the IPP brings no help. Can somebody give me a sample how to use the vm_dir_open() and the vm_dir_read() functions please?

Thanks and regards,
Otto

Hi Otto,
The vm_dir_open() and vm_dir_read() functions are Unix style directory functions as described in the ums_manual.pdf file, table 5.10 : "
Directory traverse functions Have VM unique names and serve as wrappers for the specific directory traverse functions
Ipp32s vm_dir_open(vm_dir **dd, vm_char*path); Similar to Unix opendir
Ipp32s vm_dir_read(vm_dir *dd, vm_char *filename, int nchars); Similar to Unix readdir
".
Look at this as an a piece of sample with VM directory functions. The vm_dir_open() and vm_dir_read() functions are bold faced.

#if !defined(LINUX32) && !defined(OSX)
# include
# include
# if _MSC_VER >= 1400
# pragma warning(disable: 4996)
# endif
# define TFDNAME VM_STRING("TEST\tstfile.")
# define TFDIRFULL VM_STRING("TEST2\*.*")
#else
# define TFDNAME "TEST/tstfile."
# define TFDIRFULL VM_STRING("TEST2")
#endif // if !defined(LINUX32) && !defined(OSX)
#define MESSAGE_OK {cout << VM_STRING("....... OK") << endl; }
#define MESSAGE_FAIL {cout << VM_STRING("....... FAIL") << endl;}
#define TFDIR VM_STRING("TEST")
#define TFDFILES 5
#define FAIL_BREAK {cout << VM_STRING("....... FAIL") << endl; break; }
#define SMALLSTRING 2048

...
vm_dir *tsd;
vm_char s[SMALLSTRING];

cout << VM_STRING("directory read/delete operations") << endl;
cout << VM_STRING("create directory TEST and 5 files in it") << endl;
vm_char tfdname[32];
Ipp32u i;
do {
if (!vm_dir_mkdir(TFDIR)) FAIL_BREAK
for (i = 0; i < TFDFILES; ++i) {
vm_string_sprintf( tfdname, VM_STRING("%s%01d"), TFDNAME, i);
if (((tst = vm_file_fopen(tfdname, VM_STRING("w"))) != NULL) &&
(vm_file_fwrite((void *)tfdname, 1, (Ipp32s)vm_string_strlen(tfdname), tst) == (Ipp32s)vm_string_strlen(tfdname)))
vm_file_fclose(tst);
}
if (i < TFDFILES) FAIL_BREAK
/* read directory */
vm_string_sprintf(tfdname, VM_STRING("%s*"),TFDNAME);
Ipp32u j = 0;
// try to remove test directory
cout << VM_STRING("check TEST directory contentsn");
if (vm_dir_open(&tsd, TFDIRFULL)) {
cout << VM_STRING("directory opened OKn");
while (vm_dir_read(tsd, s, SMALLSTRING)) {
cout << VM_STRING("entry in : ") << s << endl;
++j;
}
vm_dir_close(tsd);
} else {
cout << VM_STRING("errno = ") << errno << endl;
FAIL_BREAK
}
/* remove files and test directory */
cout << VM_STRING("remove files and test directory") << endl;
for (i = 0; i < TFDFILES; ++i) {
vm_string_sprintf( tfdname, VM_STRING("%s%01d"), TFDNAME, i);
if (!vm_dir_remove(tfdname))
break;
}
if (i < TFDFILES) FAIL_BREAK;
if(!vm_dir_remove(TFDIR)) FAIL_BREAK;
MESSAGE_OK
} while(0);

Regards,
Alexander

Otto_Wesso
Beginner
128 Views
simply nice, now i understand. Thank you!

Otto
Reply