Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED]how to check whether a Dir is empty or not?
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]how to check whether a Dir is empty or not?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 1.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    opengpu2
    wrote on 31 Aug 2015, 08:02 last edited by opengpu2 9 Jan 2015, 05:23
    #1

    how to check whether a Dir is empty or not?
    thank you

    1 Reply Last reply
    0
    • J Online
      J Online
      jsulm
      Lifetime Qt Champion
      wrote on 31 Aug 2015, 08:28 last edited by jsulm
      #2

      QDir("/PATH/TO/DIR").count()
      Returns 2 for empty directories ("." and ".." are counted).

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      O 1 Reply Last reply 1 Sept 2015, 01:20
      1
      • J jsulm
        31 Aug 2015, 08:28

        QDir("/PATH/TO/DIR").count()
        Returns 2 for empty directories ("." and ".." are counted).

        O Offline
        O Offline
        opengpu2
        wrote on 1 Sept 2015, 01:20 last edited by
        #3

        @jsulm is this always true? in every platform include windows, mac, linux?

        1 Reply Last reply
        0
        • J Online
          J Online
          jsulm
          Lifetime Qt Champion
          wrote on 1 Sept 2015, 04:21 last edited by
          #4

          I tested on Linux and Windows: it returns 2 for empty directories. Since MacOS X is a UNIX like system it behaves same there for sure.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          O 1 Reply Last reply 1 Sept 2015, 05:23
          0
          • J jsulm
            1 Sept 2015, 04:21

            I tested on Linux and Windows: it returns 2 for empty directories. Since MacOS X is a UNIX like system it behaves same there for sure.

            O Offline
            O Offline
            opengpu2
            wrote on 1 Sept 2015, 05:23 last edited by
            #5

            @jsulm thank you very much

            1 Reply Last reply
            0

            1/5

            31 Aug 2015, 08:02

            • Login

            • Login or register to search.
            1 out of 5
            • First post
              1/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved