comparative review – Basic Linux Commands Recreation (filesystem) In C++

Hey I’m learning the file system library and thought nothing could be better than a project so i thought of recreating the basic linux command like ls, cd etc through c++ and file system.As i said I’m learning c++ and exploring libraries there would be many weird code and all those things,could you review my code and say where i can improve the code.

My Code :

main.cpp

#include <iostream>
#include <filesystem>
#include "command.h"
namespace fs = std::filesystem;
int main()
{
    //Basic Linux Feel ;)
    std::string CurPath = fs::current_path();
    std::cout << "~";
    color::color_blue(CurPath);
    std::cout << "$ ";
    //Main Loop
    while (true)
    {
        std::string cmnd;
        getline(std::cin, cmnd);
        #if DEBUG
                if (cmnd == "exit")
                    return 0;
        #endif
        DetermineCommand(cmnd);
    }
}

command.h

#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <chrono>
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
using namespace std::chrono_literals;
//DEBUG Mode :) I Used This For Exitting The Infinite Loop
#define DEBUG 1

//Used For Setting Color To Console According To OS
class color
{
  public:
    static void color_green(std::string path)
    {
#ifndef __LINUX
        //color code for green
        std::cout << "33(32m" << path << "33(0m";
#else
        //Green
        system("Color 02");
        std::cout << path;
        //White
        system("Color 07");
#endif
    }
    static void color_blue(std::string path)
    {
//color code for blue
#ifndef __LINUX
        std::cout << "33(34m" << path << "33(0m";
#else
        //Blue
        system("Color 01");
        std::cout << path << " ";
        //White
        system("Color 07");
#endif
    }
};
//Says The Current Path Color Encoded
void SayPath()
{
    std::cout << std::endl;
    std::string CurPath = fs::current_path();
    std::cout << "~";
    color::color_blue(CurPath);
    std::cout << "$ ";
}
//cp Used For Copying Files
void cp(std::string p1, std::string p2)
{
    fs::path ToCopy = p1, Target = p2;
    if (!fs::exists(p2)|| !fs::exists(p1))
    {
        throw std::string("cp: cannot stat " + p1 + ": No such file or directory");
    }
    //Trying To Warn
    fs::path CheckExist = p2 + "/" + p1;
    if (exists(CheckExist))
    {
        std::cout << "The File Already Exist On The Given Path Replace Them (Y/N) ";
        char ans;
        std::cin >> ans;
        if (ans != 'Y' || ans != 'y')
        {
            std::cout << "Aborted!";
            return;
        }
    }
    fs::copy(p1, p2, fs::copy_options::recursive);
}
//mkdir Used For Making Directories
void mkdir(std::string &s)
{
    fs::create_directories(s);
}

//rm Used For Deleteing Files
void rm(std::string s)
{
    std::error_code err;
    //Handling The Case If Directory Doesn't Exsist
    if (!fs::exists(s))
    {
        throw std::string("rm: cannot remove '" + s + "': No such file or directory");
    }
    if (fs::is_directory(s, err))
    {
        if (fs::exists(s))
        {
            throw std::string("rm: cannot remove '" + s + "': Is a directory");
        }
    }
    fs::remove(s);
    return;
}

//The “cd” Command Used For Navigating Over Directories
void cd(std::string &path)
{
    //cd .. implementation - going to parent directory
    if (path == "..")
    {
        fs::path Parent = fs::current_path().parent_path();
        fs::current_path(Parent);
        return;
    }
    //If The User Entered A Blank Path Or Just The "cd" command
    else if (path == "")
    {
        fs::current_path(fs::current_path().root_directory());
        return;
    }
    //If Path Doesn't Exist
    else if (!fs::exists(path))
    {
        throw std::string("cd: " + path + " No such file or directory");
    }
    else
    {
        fs::current_path(path);
    }
}

//The “ls” Command Is Used For Printing All The Files And Directories In The Cirrent Folder
void ls()
{
    fs::path CurPath = fs::current_path();
    //f_name will be used for storing paths and names
    std::string f_name;
    for (auto &Name : fs::directory_iterator(CurPath))
    {
        //If It's A File
        std::error_code err;
        if (fs::is_regular_file((Name).path(), err))
        {
            f_name = Name.path().filename();
            color::color_green(f_name);
            std::cout << " ";
        }
        //If It's A Folder
        else
        {
            f_name = Name.path().filename();
            color::color_blue(f_name);
            std::cout << " ";
        }
    }
}
//mv move command
void mv(std::string From, std::string To, bool IsRename)
{
    fs::path p1 = From, p2 = To;
    //Checking If It's For Renaming
    if (!IsRename)
    {
        fs::path CheckExist = To + "/" + From;
        if (exists(CheckExist))
        {
            std::cout << "The File Already Exist On The Given Path Replace Them (Y/N) ";
            char ans;
            std::cin >> ans;
            if (ans != 'Y' || ans != 'y')
            {
                std::cout << "Aborted!";
                return;
            }
        }
    }
    fs::copy(From, To);
    fs::remove(From);
}
void rmdir(std::string Path){
    if(!fs::exists(Path)){
        throw std::string("rmdir: failed to remove "+Path+": No such file or directory");
    }
    if(!fs::is_directory(Path)){
        throw std::string("rmdir: failed to remove "+Path+": Not a directory");
    }
    fs::remove(Path);
}
//Related To File Information
std::streampos GetSize(std::string PathName){
    std::streampos FullSize=0;
    fs::path Path=PathName;
    if(fs::is_directory(Path)){
        for (auto& Name:fs::recursive_directory_iterator(Path)){
            if(fs::is_regular_file(Name.path())){
                std::ifstream Open(Name.path(),std::ios_base::binary);
                std::streampos ThisSize=Open.tellg();
                Open.seekg(0,std::ios::end);
                FullSize+=ThisSize-Open.tellg();
                Open.close();
            }
        }
        return FullSize;
    }
    else{
        std::ifstream Open(Path);
        std::streampos ThisSize=Open.tellg();
        Open.seekg(0,std::ios::end);
        ThisSize=ThisSize-Open.tellg();
        Open.close();
        return ThisSize;
    }
}
void PrintTime(std::string Path){
    //Copied From Runebook.dev ;)
    auto ftime=fs::last_write_time(Path);
    std::time_t cftime = decltype(ftime)::clock::to_time_t(ftime);
    std::cout <<std::asctime(std::localtime(&cftime));
}
void GetInfo(std::string Path){
    if(!fs::exists(Path)){
        throw std::string("--info: "+Path+" No such file or directory");
    }
    std::streampos Size=GetSize(Path);
    std::cout<<"SIZE : "<<Size<<std::endl;
    std::cout<<"PATH : "<<Path<<std::endl;
    std::cout<<"LAST MODIFIED : "; 
    PrintTime(Path);
    if(fs::is_directory(Path)){
        std::cout<<"TYPE : Directory";
    }
    else{
        std::cout<<"TYPE : File";
    }
}
void cat(std::string Path){
    if(!fs::exists(Path)){
        throw std::string("cat: "+Path+": No such file or directory");
    }
    else if(fs::is_directory(Path)){
        throw std::string("cat: "+Path+": Is a directory");
    }
    std::string Temp;
    std::ifstream Reader(Path);
    while(getline(Reader,Temp)){
        std::cout<<Temp<<std::endl;
    }
}
void help(){
    std::cout<<"•cdn•lsn•mkdirn•rmdirn•rmn•pwdn•echon•clearn•cpn•mvn•renamen•--infon•cat";
    SayPath();
}
//This Function Is Used For Determining The Type Of Command
void DetermineCommand(std::string &s)
{
    std::stringstream Extractor(s);
    std::string Type;
    Extractor >> Type;
    if (Type == "cd")
    {
        if (s.length() == 2 || s(3) == ' ')
        {
            std::string Empty = "";
            cd(Empty);
            SayPath();
            return;
        }
        //I'm Reusing The Type Variable To Store The Path As The Next Would Be The Path
        Extractor >> Type;
        try
        {
            cd(Type);
            SayPath();
        }
        catch (std::string Error)
        {
            std::cout << Error;
            SayPath();
            return;
        }
    }
    else if (Type == "ls")
    {
        ls();
        SayPath();
    }
    else if (Type == "mkdir")
    {
        std::string Path;
        Extractor >> Path;
        mkdir(Path);
        SayPath();
    }
    else if (Type == "rm")
    {
        std::string Parms;
        Extractor >> Parms;
        try
        {
            rm(Parms);
            std::cout << "b";
        }
        catch (std::string Error)
        {
            std::cout << Error;
        }
        SayPath();
    }
    else if (Type == "pwd")
    {
        std::cout << fs::current_path();
        SayPath();
    }
    else if (Type == "echo")
    {
        std::string s;
        std::string a;
        Extractor>>s;
        while(Extractor>>a){
            s+=a+' ';
        }
        if(s(0)=='"' && s(s.length()-1)=='"'){
            s.erase(s.begin());
            s.erase(s.end());
        }
        std::cout << s;
        SayPath();
    }
    else if (Type == "clear")
    {
        system("clear");
        SayPath();
    }
    else if (Type == "cp")
    {
        std::string p1, p2;
        Extractor >> p1 >> p2;
        try
        {
            cp(p1, p2);
        }
        catch (std::string Err)
        {
            std::cout << Err;
        }
        SayPath();
    }
    else if (Type == "mv")
    {
        std::string p1, p2;
        Extractor >> p1 >> p2;
        try{
            mv(p1, p2, false);
        }
        catch(...){
            std::cout<<"Some Error Occuredn";
        }
        std::cout<<'b';
        SayPath();
    }
    else if (Type == "rename")
    {
        std::string p1, p2;
        Extractor >> p1 >> p2;
        mv(p1, p2, true);
        std::cout<<'b';
        SayPath();
    }
    else if(Type=="--info"){
        try{
            std::string Path;
            Extractor>>Path;
            GetInfo(Path);
            //Flushing n
            std::cout<<'b';
            SayPath();
        }
        catch(std::string err){
            std::cout<<err;
            SayPath();
        }
    }
    else if(Type == "cat"){
        std::string FName;
        Extractor>>FName;
        try{
            cat(FName);
        }
        catch(std::string err){
            std::cout<<err<<std::endl;
        }
        std::cout<<'b';
        SayPath();
    }
    else if(Type=="--help"){
        help();
    }
    else if(Type == "rmdir"){
        std::string Path;
        Extractor>>Path;
        rmdir(Path);
        SayPath();
    }
    else{
        std::cout<<"No such command found use --help to get a list of all command";
        SayPath();
    }
}

If youre having problem seeing the code i have uploaded it on GitHub Too – Repo

Note – i didn’t implemented all versions of every command like for example i just implemented ls not other version like ls -a etc

Thanks for checking this out!!

unity – Logging of method calls for recreation

Some games have the option to let you play offline and sync with a server once you have internet again. To prevent cheating and validate if it was an authentic play, usually some sort of log of all input actions is sent and validated afterwards on the server.

In my case I would be interested in a single MonoBehaviour and having all its method calls logged with the its parameters values. Giving this input, the game result output should be the same. (There is no random involved and no physics interaction)

  • One way would be just a writer at the start of each method that logs the timestamp, method name and paramter
  • Another would be maybe something like a multi delegate inbetween that calls both my method and a writer class
  • There is something else (some audit interface, annotation, etc)

What is the best way to achieve the logging? (No the actual format, just how to setup the framework to do the logging)

planning – Are there any topographic or recreation atlases of Germany or the Alpine countries?

I’m looking for a topographic or recreation atlas for Germany and/or the Alpine countries. Does such an atlas exist?

There are plenty of road atlases (ADAC, Falk, Michelin, others) in scales between 1:150k and 1:300k, but those are entirely focussed on driving a car, with little topographic information; at best they have hill shading and important rivers. Apart from some stars or circles drawn on the map and displaying some campgrounds, there is little practical information on recreation. For example, they’re of little value for planning cycle touring trips.

There are topographic maps in scale 1:250k for sale at Bundesamt für Kartographie und Geodäsie. 30 sheets cover Germany, but this appears to be available only as paper sheets, not in a browsable book form. Swisstopo has excellent 1:200k overview maps as well (4 sheets cover the entire country).

I found the Topographischer Atlas Bundesrepublik Deutschland, which would satisfy my demand, but it appears to be last updated in 1977, which is rather old. There also appears to be a DVD version from 2006, advertising it includes “all 12 volumes on one DVD”; I’m not sure volumes of what, and I don’t know if it’s all thematic maps or also geographic/topographic maps covering the country in some detail.

What I’m looking for is either something like:

  • the topografische atlas van Nederland (a Dutch topographical atlas (although for Germany it’d have to be either per state/region or in a smaller scale)), or
  • the Национальный атлас России (national atlas of Russia), or
  • something like the Benchmark Maps Road & Recreation Atlases in the western United States; although those aren’t topographic, their maps are doing a better job showing the landscape than any European road maps/atlases I’ve seen and there’s plenty of recreation information too.

Does something like this exist for either Germany or the Alpine Countries, preferably from the last 25 years?

I love browsing beautiful paper maps, and it could be a great inspiration for yet-undiscovered travel destinations that don’t require flying halfway across the world.

Sell: outdoor recreation product review website, monetized by Amazon | Proxies123.com

Hello,
I want to sell my website for outdoor recreation product reviews.

The place: https://www.OutdoorsRecreation.net

Information:
OutdoorsRecreation is a product review website.
All 10 articles are UNIQUE and written by professional writers include the review of each Amazon product.
The website created with WordPress CMS, so it is easy to maintain, edit and add content.gt

Improvement:
As you can see the store after optimization and loaded below 1 second,
https://gtmetrix.com/reports/www.outdoorsrecreation.net/tXXZ1gYU
* $ 250 value

Traffic:
The website does not have much traffic.

For the buyer:
I release the domain through Name.com.
I will send you all the content of the site.

Price – $ 199 OBO.

Payment – Paypal

Greetings.

Outdoor recreation product review website, monetized by Amazon

Hello,
I want to sell my graphic card comparison website.

The place: https://www.OutdoorsRecreation.net

Information:
OutdoorsRecreation is a product review website.
All 10 articles are UNIQUE and written by professional writers include the review of each Amazon product.
The website created with WordPress CMS, so it is easy to maintain, edit and add content.gt

Improvement:
As you can see the store after optimization and loaded below 1 second,
https://gtmetrix.com/reports/www.outdoorsrecreation.net/tXXZ1gYU
* $ 250 value

Traffic:
The website does not have much traffic.

For the buyer:
I release the domain through Name.com.
I will send you all the content of the site.

Price – $ 199 OBO.

Payment – Paypal
SEMrush

Greetings.

Active directory: AD user recreation, security issue

I have some users who prefer to re-create a user instead of resetting the password (or investigate why there is a problem with the account).

Personally, I have found that this is a general bad practice for an administrator and a suspicious pattern from the point of view of security (change of user SID, so we can lose traceability).

Do you think this is a real safety concern?

Thank you.

Israel dating free dating site for Scotland 6237

Afterbarbag
reviewed by Afterbarbag in
.
Israel dating free dating site for Scotland 6237
match available indian dating online websitessimply dating websitesglock dating dating chartonline app success stories, I just started dating to keep interested a single girl who is in the place speed of dating christian dating dating on the site dating people in the city, dating, dating, dating, dating, home, connections, crosswords, cabins, dating, places, dating, dating in Adelaidehookup, culture, and dating site of girlfriendbest in portugalonline should be
Classification: 5

.

Buy a definition essay on how to find someone to write a case study on recreation

Help with Mayfield courses we will write your 20 page document

High quality essay writing service

[​IMG]

Writing services – ASK HERE

The president of PSG issues a statement of support to Chief Thomas Tuchel. The man faked cancer by putting a straw in his pants and pretending it was the top of a colostomy bag.
Why was Lonely Planet right when he said that Sri Lanka is the best place to visit in 2019?
"Try calling your family doctor … a farmer in Rwanda has faster access to medical care"
Literature review on genetic engineering. Help of gcse sociology courses.
Mother and son imprisoned for keeping two Slovak men as slaves & # 39; for eight years Can hashtag activism save kidnapped Nigerian girls?
Case study on osteotomy. Help with my mathematical tasks.
In baseball after a wave of offers, Zack Greinke still stands alone
Reliable and inexpensive essay writing service for someone to write my review of tax literature
Review of recent extraterrestrial abductions, anguish is a driving force The Stubai glacier in Austria is the place to go skiing during Easter The team fed with 250 kg of food Health officials ask grieving parents to donate the organs of their children in the midst of donors for islanders and fanatics No place like home or home A review of a provocative new book about the woman who inspired Socrates
Help me write a case study on the turbo compiler c make for me level 1 trial
Inside United's locker room, Jubilant stars jump and sing after an incredible recovery NASA clears the SpaceX test flight to Emmanuel Macron space station among the brilliant preselected images for the news photo of the year Jeremy Corbyn faces a Large-scale humiliating investigation into the alleged anti-Semitism crisis Ghosn The defense team monitors calls and surveillance images while awaiting trial. Muhammadu Buhari wins second term as president of Nigeria.
To trade with a future father? Weve Seen Stranger The Wassaic project A festival, a beautiful flood and now art
Professional thesis writers who can write literature review on turbines.
Help with article r
Help write my level 9 rehearsal algorithms help with homework
Can I buy creative writing at a fun fair to buy a research job from the UK?
How to find someone to write an essay of mla research paper on ibm

Oracle: the stored procedure stopped producing output after the recreation.

I have made changes to a custom stored procedure using the "create or replace procedure" syntax through Oracle SQL Developer, and after the storage procedure stopped returning rows (saving to a file, the file length is now 0 , while there is data). The change was minimal, simply by changing a DATE field for concatenation in a chain. I returned the sproc to the original, but it is still not giving any results.

I have logged in as "installer" in SQL Plus and OSD, and sproc is invoked in this way (from SQLPlus and O.S.D.):
exec installer.sp_exportMemo (sysdate-3);

I was thinking that maybe CREATE OR REPLACE made some permission changes, so I went to the Perform Grant Action screen for that sproc, and I selected "installer", and in the left window I see
RUN
GRANT
And I tried to click on "Grant everything" and move EXECUTE and GRANT to the right window, but when I check again, EXEC and GRANT are still in the left window.
I work mainly with MS SQL, but I am not familiar with Oracle to solve this, I can not even show the result set on the screen, but there were no errors during the compilation or execution of this sproc.

Contest – Easy recreation of $ 10 image

Advertising

you do not do?

Advertise virtually anything here, with CPM ads, CPM email ads and CPC contextual links. If you wish, you can go to relevant areas of the site and display ads based on the user's geographic location.

Start at only $ 1 per CPM or $ 0.10 per CPC.