Code Monkey home page Code Monkey logo

file-copy's Introduction

CSC 415 - Project 2 - File copy

Student Name : Brian Lai

Student ID : 916818167

Build Instructions

Windows

gcc filecopy.c [filename]

or if make is configured in %PATH% with MinGW or Cygwin

make

Mac OS X

make

Linux

make

Run Instructions

Windows

If no filename was given

./a

If filename was given while building, where filename is the file's name

./filename

If make was used

./fc

Mac OS X

./fc

Linux

./fc

What the program does

This program copies one file to another, overwriting the file if it already exists or creating a new file if it does not exist. Specify the filename of a source file in the current directory to copy and specify the filename of a destination file to copy to. The destination file does not have to already exist and file extensions do not need to be maintained.

strace/dtruss output

Welcome to the File Copy Program by Brian Lai
Enter the name of the file to copy from:
LICENSE
Enter the name of the file to copy to:
LICENSEE
File Copy Successful, 1074 bytes copied
% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
  // Reading the file, called 56 times because of the buffer size,
  // how big the source file is, and other internal system libraries
  0.00    0.000000           0        56           read

  // Writing to the file, called 56 times because of the buffer size,
  // how big the destination file is, and other internal system libraries
  0.00    0.000000           0        56           write

  // Closing files, called twice for source file and destination file,
  // two more calls for file descriptors
  0.00    0.000000           0         4           close

  // Used to read permissions from source file
  0.00    0.000000           0         1           stat

  // Determines what to do with the file based on the file descriptor
  // Reads from source file and write to destination file
  // Other two calls are for internal system libraries
  0.00    0.000000           0         4           fstat

  // Called at the end of the file before returning 0
  // Used to move the read/write pointer of a file descriptor
  // Returned -1 so an error occurred when trying to move the pointer
  0.00    0.000000           0         1         1 lseek

  // Allocates memory for file desciptors, sets permissions,
  // offsets the start of memory address
  0.00    0.000000           0         5           mmap

  // Set protection for permissions on memory
  0.00    0.000000           0         4           mprotect

  // Release memory starting at an address
  0.00    0.000000           0         1           munmap

  // Finds location of the pointer to memory and end of memory address
  0.00    0.000000           0         3           brk

  // Check if file exists with read access
  0.00    0.000000           0         3         3 access

  // Executes this program in memory, called at the very beginning
  0.00    0.000000           0         1           execve

  // Used to write permissions from source file to destination file
  0.00    0.000000           0         1           chmod
  0.00    0.000000           0         1           arch_prctl

  // Open files, called twice for source file and destination file,
  // two more calls for internal system libraries
  0.00    0.000000           0         4           openat
------ ----------- ----------- --------- --------- ----------------
100.00    0.000000                   145         4 total

file-copy's People

Contributors

asouza88 avatar blai30 avatar

Stargazers

 avatar

Watchers

 avatar

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.