Recap 10_10_15

Source control - Reading Files - CV

Objectives

  • Source control
    • SVN
    • GIT
    • GitHub
  • ​​Files
    • Text
    • Binary​

Creating local repository

With TortoiseSVN creating a local repository is as easy as right clicking on a directory and Choosing 

TortoiseSVN -> Create repository here

I would recommend to create a designated repository folder. Lets say C:\SVN

And a repository of each project

Say C:\SVN\Project1 so right click on Project1 to make it a repository

Creating local repository 

You can than continue and Create folder structure, BUT for local repository with only 1 contributor I don't see the advantages. This is good when forking is anticipated. 

NOTICE: The full address of the repository highlighted in blue 

file:///<Absolute path to Project>/<Project Name>

Checkout the Repository

A Repository will manage our files versions. We, however, work with a local(Checked-out) copy

 

Ad hoc recommendation to create some Projects folder

for example c:/Projects

and add a directory per project so in our case 

c:/Projects/Project1

we than go to that Project directory, right-click on the empty space and do SVN-Checkout

Checkout the repository

You fill the URL of the repository and normally it should just be fine to just click OK.

 

 

Once that is done, we have a repository at c:/SVN/Project1 to handle the versioning for us (We don't normally touch it).

And a working local copy at c:/Projects/Project1 where we Add/Remove elements as well as check-in and check-out using TortoiseSVN

Creating local repository

Unlike SVN in windows, for GIT there 2 two installations required

But otherwise the Creating local repository is similar to the TortoiseSVN.

Assuming I want to keep all my GIT repositories at c:/GIT and I have a repository for Project1 at c:/GIT/Project1

We create the two folders, right click on Project2 folder and  

 

Cloning a local working project

To creating our working copy (We do not touch the repository), We create the folder c:/Projects/Project2, go to that folder and right-click anywhere.

Than we choose Git Clone.  Just like SVN we supply the location of the repository

et voilla.

GitHub with windows

GitHub is an (mostly free) online repository service, so it has some advantages 

  • The revisions are accessible from any connected device 
  • Loss of data is far less likely
  • Sharing 
  • Collaborating 

Disadvantages

  • The free services does not support private repositories
  • Must be connected to the Internet

 

First, you must create a GitHub account

And than you can install GitHub Desktop for windows which should provide you will the interface to create Repositories and work with them. BitBucket is an alternative

 

Reading files

Text Files

Usually read using streaming operators 

#include <iterator>   //  For output_iterator

fstream file("filename", ios::out | ios::binary);
vector<char> buffer(istreambuf_iterator<char>(file)), istreambuf_iterator<char>());
file.close();
#include <iterator>   //  For output_iterator

fstream file("filename", ios::out | ios::binary);
int i; 
string str;
file >> i >> str; // Reads and integer and a string, separate by whitespace 
file.close();

Can be entirely read using the istreambuf_iterator

Reading files - binary

Binary files

files are read using read operator which also specifies the number of bytes to read.

 

std::fstream fstr(fileName, std::ifstream::binary | std::ifstream::in)
char buffer[100];
fstr.read(buffer, 100)
fstr.close()

deck

By perplexedpigmy

deck

  • 1,031