Thread: Messing with folders

  1. #1
    Registered User
    Join Date
    Dec 2005
    Posts
    17

    Messing with folders

    Hello c++ people!
    Well... Have you guys ever seen when you right click on a folder and see it proprieties?
    I want to make a program that will check for the folders in a root (for example: folder 1, folder 2, folder 3) and will save in a file the folder info (like how much files there is inside the folder, the total size of the folder, etc...)
    How do i do that? Thanks ^^

  2. #2
    Registered User
    Join Date
    Mar 2006
    Posts
    725
    Well, you'll need to access the folders nd files in them, and that's a little bit platform-dependant. You can use POSIX opendir(), readdir() etc if you have them, and stat() to get file properties. If you're on Windows I'm sure there are loads of directory handling functions you can use; refer to MSDN.

    But if you want my honest opinion, the quickest, easiest way to do this is to dump C++ altogether and use #!/bin/sh or whatever else your system provides.
    Code:
    #include <stdio.h>
    
    void J(char*a){int f,i=0,c='1';for(;a[i]!='0';++i)if(i==81){
    puts(a);return;}for(;c<='9';++c){for(f=0;f<9;++f)if(a[i-i%27+i%9
    /3*3+f/3*9+f%3]==c||a[i%9+f*9]==c||a[i-i%9+f]==c)goto e;a[i]=c;J(a);a[i]
    ='0';e:;}}int main(int c,char**v){int t=0;if(c>1){for(;v[1][
    t];++t);if(t==81){J(v[1]);return 0;}}puts("sudoku [0-9]{81}");return 1;}

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    There's an FAQ on the subject: http://faq.cprogramming.com/cgi-bin/...&id=1044780608

    I want to make a program that will check for the folders in a root (for example: folder 1, folder 2, folder 3) and will save in a file the folder info (like how much files there is inside the folder, the total size of the folder, etc...)
    Like this? (All files.)
    Code:
    $ stat `ls *` >> folderinfo
    or this? (Directories only.)
    Code:
    #!/usr/bin/perl
    
    foreach(<*>) {
        if(-d) system("stat $_ >> folderinfo");
    }
    or this? (DOS folder-only listing.)
    Code:
    dir /ad /b > folderinfo.tmp
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Error while trying to list folders
    By Hellbinder in forum Networking/Device Communication
    Replies: 5
    Last Post: 06-12-2009, 05:27 PM
  2. Problems Moving Certain Folders...
    By notsocks in forum C Programming
    Replies: 8
    Last Post: 12-16-2007, 07:25 AM
  3. Help with folders
    By FlyingIsFun1217 in forum C++ Programming
    Replies: 5
    Last Post: 10-21-2006, 09:41 AM
  4. Deleting folders and sub folders
    By Boomba in forum C++ Programming
    Replies: 30
    Last Post: 06-11-2003, 11:58 AM
  5. Folders and text files
    By tim545666 in forum C++ Programming
    Replies: 11
    Last Post: 02-17-2002, 04:15 PM