dirent | C/C++ library for retrieving information on files | File Utils library

 by   tronkko C Version: 1.23.2 License: MIT

kandi X-RAY | dirent Summary

kandi X-RAY | dirent Summary

dirent is a C library typically used in Utilities, File Utils applications. dirent has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. You can download it from GitHub.

Dirent is a C/C++ programming interface that allows programmers to retrieve information about files and directories under Linux/UNIX. This project provides Linux compatible Dirent interface for Microsoft Windows.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              dirent has a medium active ecosystem.
              It has 917 star(s) with 523 fork(s). There are 39 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 0 open issues and 24 have been closed. On average issues are closed in 42 days. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of dirent is 1.23.2

            kandi-Quality Quality

              dirent has no bugs reported.

            kandi-Security Security

              dirent has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.

            kandi-License License

              dirent is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              dirent releases are available to install and integrate.
              Installation instructions, examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of dirent
            Get all kandi verified functions for this library.

            dirent Key Features

            No Key Features are available at this moment for dirent.

            dirent Examples and Code Snippets

            No Code Snippets are available at this moment for dirent.

            Community Discussions

            QUESTION

            Count Files in directory and subdirectory in Linux using C
            Asked 2021-Jun-08 at 17:08

            I am trying to count files of a directory and its subdirectories. But I am getting a seg fault every time and I don't see why.

            I used the code from here: Counting the number of files in a directory using C

            Thanks for help

            ...

            ANSWER

            Answered 2021-Jun-08 at 17:08

            printf does not take an integer. It takes a format string and a variable list of arguments. Your problem can probably be fixed by changing:

            Source https://stackoverflow.com/questions/67891529

            QUESTION

            Trying to read files in directory, directory just leads to himself and loops in himself
            Asked 2021-Jun-04 at 20:55

            So the code idea is as following: i pick a path in the main, go in it, if i encounter a file, just save its name and modification date in the .txt file, otherwise it should open the directory it just found, get inside and re-do the process for this directory

            The rest of the process works quite fine, UNTIL i uncomment the recursive part, where it will proceed to go in itself i think (Path.), then loops to that state (go to Path.., Path... , etc), making the thing completely useless and justan infinite loop

            Any ideas?

            ...

            ANSWER

            Answered 2021-Jun-04 at 20:51

            (dir->d_name) !=".." is not a valid way to check if dir->d_name is equal to the string "..". You need to use strcmp(dir->d_name, "..");

            The string literal ".." refers to a location in memory which contains the 3 bytes ., ., and \0. It is entirely possible for dir->d_name to also contain those same bytes, but since it is in a different place dir->d_name == ".." will be false. But strcmp(dir->d_name, "..") will evaluate to zero if the contents of the two locations are the same.

            Source https://stackoverflow.com/questions/67843668

            QUESTION

            c code to compare two binary files runs on windows but won't run on Linux
            Asked 2021-May-15 at 17:43

            I wrote a c code on visual studio to compare binary file to search a know virus in other binary file.
            the code is running on my windows PC perfectly however it won't compile on the Linux test of my collage.

            the code receive a folder containing the files and the file of the virus


            this is the code adjusted for Linux that i sent to the test

            ...

            ANSWER

            Answered 2021-May-15 at 17:43

            Pasting your code into godbolt quickly reveals the problem. struct stat isn't defined. For linux, you need to #include and #include for struct stat. Pay attention to the remaining warning(s).

            Source https://stackoverflow.com/questions/67549395

            QUESTION

            In C, how to match d_type value to "state" of element?
            Asked 2021-May-15 at 09:17

            I am listing elements in a directory in C.

            I use the following code:

            ...

            ANSWER

            Answered 2021-May-15 at 09:17
            1. Values because they are enums. ref: https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6/+/refs/heads/jb-dev/sysroot/usr/include/dirent.h
            2. Types are not consistent across OS so need to check "dirent.h" or "sys/types.h" of that OS. ref: https://c-for-dummies.com/blog/?p=3252

            You can also use stat function to know if its a file or directory from "sys/stat.h"

            below example in case you want to print file or dir:

            Source https://stackoverflow.com/questions/67544777

            QUESTION

            Error when storing names of subdirectories as nodes in list
            Asked 2021-May-04 at 20:17

            I open a directory that has multiple subdirectories with names of countries. What i want is to make a list and store the paths of these directories in the nodes. The issue comes up when i print the list and in the destructor. I don't seem to get what's wrong since i've used these functions multiple times before with no issue coming up.

            The directory looks something like this:

            ...

            ANSWER

            Answered 2021-May-04 at 20:17

            You never set newnode->next to NULL. So when you loop through the list of nodes, you run into an unitialized pointer when you get to the last node.

            You can change the CountryNode constructor to initialize it to this default.

            Source https://stackoverflow.com/questions/67391514

            QUESTION

            Error while trying to send a message with FIFO
            Asked 2021-May-03 at 20:23

            I'm new to this kind of programming so i'm sorry in advance if it's a dump question.I'm trying to do a very simple task but i don't seem to get what goes wrong.

            I have a parent process that creates a number of children processes, and with the usage of FIFOs i want to send a message to all of the children (e.g "hi"), the message get's received by the processes but there is an error coming up no matter what i do and can't seem to find what's wrong.

            Here is the parent's main function:

            ...

            ANSWER

            Answered 2021-May-03 at 20:23

            In send_message, you always write 9 bytes from buffer, but not all of those bytes have had a value written to them. This is because the sprintf that populates buffer only writes to the first few locations, possibly as few as 3.

            The solution is to either initialize them all to 0

            Source https://stackoverflow.com/questions/67375261

            QUESTION

            Last Modified of a File in Folder of C Program
            Asked 2021-Apr-29 at 02:04

            My goal is to try to get the name, size and last modified of a folder. I have used dirent.h to get the first two types. I don't know what the best way of getting the last modified value is, but the current way I am using does not seem very useful. I am getting type errors when trying to get my path as the dirent folder that I am opening. I'm not sure if there is an easier way to do this or but any guidance would be much appreciated. I found an example of how to get the last modified on stackoverflow and was trying to use that... below is my code:

            ...

            ANSWER

            Answered 2021-Apr-29 at 02:04

            folder is the return value of opendir(".");. opendir returns either a DIR* structure or NULL. Not the directory path expressed using characters.

            When you call getFileCreationTime(folder); you are sending a DIR* to your function. But you are expecting a char* path. So do not pass a DIR*, pass it the characters representing your directory. In your case "." (as used in your opendir() statement above).

            Obviously, your directory name could be stored in a variable.

            Source https://stackoverflow.com/questions/67309487

            QUESTION

            Pass char pointer to push_back vector of strings
            Asked 2021-Apr-27 at 22:20

            Is below code adding valid strings to the vector?

            ...

            ANSWER

            Answered 2021-Apr-27 at 22:20

            Yes, this code is fine 1, and it will invoke the std::string(const char*) constructor as expected, since dp->d_name is a (null-terminated) char[] array that will decay into a char* pointer.

            1: provided that push_back() does not raise an exception, otherwise the DIR* will be leaked.

            Note that calling push_back() with a char* will make a temporary std::string that will have to be copied/moved into another std::string that is constructed internally by the vector. In C++11 and later, you can use emplace_back() instead to avoid making that initial temporary:

            Source https://stackoverflow.com/questions/67291327

            QUESTION

            Find all files containing search term except sub elements
            Asked 2021-Apr-24 at 20:25

            I'm trying to make a C program that will display all the files and folders containing a given search term. The search term is given as an argument when executing the program. A folder / file is displayed to standard output if its name contains the search term (case insensitive). The difficulty though is that I do not want to output files and subfolders that are contained in a folder that contains the search term. Here's an example:

            Let's assume my search term is docker, this is the current output:

            ...

            ANSWER

            Answered 2021-Apr-24 at 19:32

            Thanks to @KamilCuk I was able to solve my issue. Here's my final listFilesRecursively function:

            Source https://stackoverflow.com/questions/67237886

            QUESTION

            Why do I get this warning when using a PushButton simple callback in Motif?
            Asked 2021-Apr-10 at 10:42

            I am trying to compile this excerpt of code without errors:

            ...

            ANSWER

            Answered 2021-Apr-10 at 10:42

            The type of the last argument for select_printer doesn't match what XtAddCallback expected for its callback.

            The select_printer function have a XmPushButtonCallbackStruct * argument, while the callback should have a void * argument.

            My suggested fix is to change the last argument of select_printer to a void *, and then inside select_printer cast the argument to its correct type. Like:

            Source https://stackoverflow.com/questions/67033381

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install dirent

            Download the latest Dirent installation package from GitHub and unpack the installation file with 7-zip, for example. The installation package contains dirent.h file as well as a few example programs and tests.
            To make dirent.h available for all C/C++ programs, simply copy the include/dirent.h file to the system include directory. System include directory contains header files such as assert.h and windows.h. In Visual Studio 2008, for example, the system include may be found at C:\Program Files\Microsoft Visual Studio 9.0\VC\include. Everything you need is included in the single dirent.h file, and you can start using Dirent immediately -- there is no need to add files to your Visual Studio project.

            Support

            We love to receive contributions from you. See the CONTRIBUTING file for details.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/tronkko/dirent.git

          • CLI

            gh repo clone tronkko/dirent

          • sshUrl

            git@github.com:tronkko/dirent.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular File Utils Libraries

            hosts

            by StevenBlack

            croc

            by schollz

            filebrowser

            by filebrowser

            chokidar

            by paulmillr

            node-fs-extra

            by jprichardson

            Try Top Libraries by tronkko

            js-vector

            by tronkkoJavaScript

            php-config

            by tronkkoPHP

            SoundHunter

            by tronkkoJava

            js-test

            by tronkkoJavaScript

            t7

            by tronkkoC