Advertisement
Guest User

Untitled

a guest
May 20th, 2019
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <sys/types.h>
  4. #include <dirent.h>
  5. #include <libgen.h>
  6. #include <sys/stat.h>
  7. #include <fcntl.h>
  8. #include <unistd.h>
  9. #include <dlfcn.h>
  10. #include <link.h>
  11.  
  12.  
  13.  
  14. void dalbut_readdir( DIR *dir, int fd );
  15. int dalbut_open_fd();
  16.  
  17.  
  18.  
  19.  
  20. int dalbut_open_fd(){
  21. int fd;
  22. fd = open( "f_info.txt", O_RDWR | O_CREAT | O_APPEND, 0644 );
  23. if( fd == -1){
  24. perror("f_info.txt");
  25. exit(1);
  26. };
  27. return fd;
  28.  
  29. }
  30. void dalbut_readdir( DIR *dir ,int fd) {
  31. struct dirent *dp;
  32. int i = 0;
  33.  
  34. while( (dp = readdir (dir)) != NULL ){
  35. printf("%3d. Vardas: %s\n%4s Nr. i-node: %i\n", ++i, dp->d_name, "", (int) dp->d_ino);
  36. void *asdd;
  37. if((asdd = dlopen(dp->d_name, RTLD_LOCAL)) == NULL){
  38. }else{
  39. printf("%s\n","dinamine biblioteka");
  40. }
  41.  
  42.  
  43. }
  44.  
  45. }
  46.  
  47.  
  48.  
  49. int main( int argc, char * argv[] ) {
  50. printf("%s\n","(C) 2019 D. Butrimas");
  51. int fd = dalbut_open_fd();
  52. DIR *dir;
  53. if ( (dir = opendir(argv[1])) == NULL ) {
  54. perror( "Cannot open ." );
  55. exit( 1 );
  56. }
  57. dalbut_readdir( dir, fd );
  58.  
  59. printf("%s%s,%s\n","Informacija apie katalogo",argv[1],"suformota f_info.txt");
  60.  
  61. if ( (closedir( dir )) != 0 ) {
  62. perror( "Failed to close .");
  63. exit( 1 );
  64. }
  65.  
  66. return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement