Git Product home page Git Product logo

dircount's Introduction

Dircount assignment

CS426

1 - prints every full pathname

1 - prints a [f] or a [d] next to the path depending on type

1 - counts the total number of files

1 - counts the total number of directories

1 - Never count the same file twice, even if there are links.

1 - does not go into an infinite loop even if the diretcory structure has loops

1 - prints the total on disk space used. (NOT the sum of all the file sizes)

-1 - Each day after Wed Oct 26th.

There is no way to tell the exact amount of disk space used by a file. However, st_blocks * 512 bytes is a pretty good guess.

The way to detect duplicate entries is to examine the st_ino structure. Each link should print the path name, but should only count once for the totals.

There are hard links and soft links. Soft links are read using readlink. See https://linux.die.net/man/2/readlink.

The article at http://stackoverflow.com/questions/8436841/how-to-recursively-list-directories-in-c-on-linux might be helpful.

You can find the inode number of a file by typing "ls -li filename".

You may assume that no path exceeds 2048 bytes long.

Calling readdir on a link will fail. Use readlink.

  • test1 - has a single, empty file.
  • test2 - has a subdir that has a file within it.
  • test3 -- Has two hard links that are the same file.
  • test4 -- Has a loop for directory soft links.
  • test5 -- Has a soft links that points to a normal file.
  • test6 -- Has a link the loops back, and several files scattered around.
  • test7 -- Has a different link loop.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.