Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    Check if Directory is empty

    Scheduled Pinned Locked Moved SDK Help
    9 Posts 0 Posters 794 Views
    Loading More Posts
    • 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.
    • H Offline
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 11/10/2008 at 15:32, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   R11 
      Platform:   Windows  ;   Mac OSX  ; 
      Language(s) :   C.O.F.F.E.E  ;

      ---------
      Getting the grips of adding, reading, deleting etc. files pretty well.
      As of R11, I'd like to add my licenses in the UserPrefs as suggested, in a folder.
      But, if there are now license files in this folder, I'd like to
      delete it as well.

      So what I can't figure out is how to check for an empty directory
      (Folder with no files in it on the disc).
      I can brows to this folder but then since I have no name to add
      to the path I'm stuck.

      Any pointers of how to do that?

      Cheers
      Lennart

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 11/10/2008 at 16:03, xxxxxxxx wrote:

        Use the BrowseFiles class.

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 11/10/2008 at 16:45, xxxxxxxx wrote:

          Hi Robert. Yup that is what I'm trying.....
          But I can't get a TRU or FALSE out of it as it seems..

          > \>         var bf = new(BrowseFiles); \>       var path = GeGetStartupWritePath(); \>       path->AddLast("MyFolder"); \>       bf->Init(path,FALSE); \>       var name = bf->GetName(); \>       if(name) \>       println("Name is ",name); \>

          Thing is this only prints the "Name is" part, the rest (var name)
          simply doesn't print anything, its blank(!?).

          So, I'm still a bit lost I'm afraid..
          There is the GetNext() option, but not "GetDown()" or GetIn() to
          "get into" the folder to check.

          Cheers
          Lennart

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 11/10/2008 at 16:55, xxxxxxxx wrote:

            There is an example at the bottom of the BrowseFiles documentation:

            var bf   = new(BrowseFiles);
            var path = GeStartupPath();

            bf->Init(path,FALSE);

            while (bf->GetNext())
            {
                if (bf->IsDir())
                  println("dir ",bf->GetName());
                else
                  println("file ",bf->GetName());
            }

            bf->GetNext() gets the first then next files/folders under the folder set in bf->Init().

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

              On 11/10/2008 at 17:15, xxxxxxxx wrote:

              Ah, I used that example to start with and also got that "blank" print.
              Just tried this:

              > \> var bf   = new(BrowseFiles); \> var path = GeGetStartupWritePath(); \> path->AddLast("MyFolder"); \> bf->Init(path,FALSE); \> \> if(bf->GetNext() != FALSE) \> println("Something here!"); \> else \> println("Nope, emty"); \>

              And even if MyFolder was empty, it wasn't!
              There is a frigging hidden ".DS_Store" file there!

              So the BrowseFiles seems to work but what to do with hidden files?
              I'm on Mac, is there anything similar happening in Windows?

              Cheers
              Lennart

              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                On 11/10/2008 at 17:54, xxxxxxxx wrote:

                On that in COFFEE, I don't know. You may need to check for that particular file by name when you get a hit, ignore it and continue on.

                1 Reply Last reply Reply Quote 0
                • H Offline
                  Helper
                  last edited by

                  THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                  On 11/10/2008 at 18:09, xxxxxxxx wrote:

                  Thanks Robert.
                  It looks as if I'm on the wrong track anyway....
                  Recreating the "MyFolder" (From Finder) so there is nothing in it,
                  even no .DS_Store file, I still get a "Something here!" using the code
                  above.

                  Maybe someone from Maxon have a tip after the weekend.

                  Cheers and thanks
                  Lennart

                  1 Reply Last reply Reply Quote 0
                  • H Offline
                    Helper
                    last edited by

                    THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                    On 20/10/2008 at 05:44, xxxxxxxx wrote:

                    I can not confirm this. If I create an empty folder on OSX with Finder->New Folder it is empty for Cinema as well. My code:

                    > \> var path = new(Filename); \> if(!path->PathSelect("Select Path")) return; \> \> var bf = new(BrowseFiles); \> bf->Init(path,FALSE); \> \> if(bf->GetNext()) println("not empty"); \> else println("empty"); \>

                    cheers,
                    Matthias

                    1 Reply Last reply Reply Quote 0
                    • H Offline
                      Helper
                      last edited by

                      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                      On 20/10/2008 at 05:47, xxxxxxxx wrote:

                      Thanks Matthias. I got it working (and have learnt a lot about file handling the last couple of days because of making license files:) )
                      Sorry to not tell.

                      Cheers
                      Lennart

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post