-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Abs and rel path #2
base: master
Are you sure you want to change the base?
Conversation
Elsokent takaritsatok ki ezt a sok szemet file-t. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Van itt baj. Pl.:
wajzy@lenovo:/Letöltések/SZE-MoSzE-2019-AC-DC$ ./bin.out$ mkdir egy/ketto/harom
/
/$ ls$ cd egy
egy/ketto/harom
/
ERROR: No directory with that names exists.
/~$
A kódotok nem tartja be az OO elveket, és nem hatékony. Utóbbi csak zavar, de az elsőt semmiképpen sem tudom elfogadni.
all: Project1/Source.o Project1/Folder.o | ||
g++ -o bin.out Project1/Source.o Project1/Folder.o | ||
|
||
Source.o: Project1/Source.cpp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, ebbe a sorba nem kellene felvenni a Folder.h-t is?
|
||
} | ||
bool parametercheck(vector<string> command, int parameternm =1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nekem úgy tűnik, ez a függvény ekvivalens ezzel:
return command.size() > parameternm;
De valóban egy függvény adja a leghatékonyabb megoldást ennek a kérdésnek az eldöntésére?
tempFolder.AbsolutePath.push_back(name); | ||
return tempFolder; | ||
} | ||
vector<string> Folder::split(string input, char charsplit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A függvényetek működik, de
-
valójában ez lehetne statikus, vagy akár osztályokon kívül definiált függvény, mert semmit nem használ az objektum adattagjaiból.
-
Lehet ezt egyszerűbben is, pl.
vector split (const string &s, char delim) {
vector result;
stringstream ss (s);
string item;while (getline (ss, item, delim)) {
result.push_back (item);
}return result;
}
Nem én vagyok ennyire okos, itt találtam egy guglizás után: https://stackoverflow.com/questions/14265581/parse-split-a-string-in-c-using-string-delimiter-standard-c
if (tree[i].AbsolutePath == tempvector) | ||
{ | ||
return tempvector; | ||
error = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Erre a sorra mikor kerül a végrehajtás?
} | ||
|
||
} | ||
if (error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Detto, magának az error változónak sincs így értelme: ha nincs hiba, akkor úgyis visszatérünk már korábban return-nel, ha meg nem térünk vissza, akkor az error garantáltan true marad, nincs mit ellenőrizni rajta.
#include "Folder.h" | ||
|
||
|
||
|
||
bool Folder::dirnamecheck(vector<Folder> tree, vector<string> currentpath, string name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ha jól látom, ez a függvény sem használja az objektum egyetlen változóját sem.
string parentfolder; | ||
string type; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ez az a típus, ami lehet file értékű? Túl azon, hogy a string típus egyszerűen túl "sok" ide, meglehetősen félrevezető a névadás.
string name; | ||
vector<string> AbsolutePath; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Miért kell minden mappáról külön eltárolni az összes szülőjét? Miért nem elég a szülő mappát tárolni, akitől meg lehet kérdezni az ő szülőjét, és így tovább, vissza egészen a gyökérig? Nagyon memóriapazarló és lassú adatszerkezetnek tűnik nekem ez. Ha ellenőrizni akarom egy fájlbejegyzés létezését, akkor az összes létező bejegyzést egyesével végig kell majd nézegetnem, ahelyett, hogy kihasználnám a fa tulajdonságait, és egyre kevesebb elemből álló részfákat kellene csak átbogarászni.
public: | ||
bool dirnamecheck(vector<Folder> tree, vector<string> currentpath, string name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tehát ha jól értem, akkor itt minden adattag nyilvános. Hogyan valósul meg így az adatrejtés OO elve?
} | ||
return true; | ||
} | ||
Folder Folder::mk(vector<Folder> tree, vector<string> currentpath, string name, string type ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Akkor jól értem, hogy ez van konstruktor helyett? Mi indokolja ezt a szokatlan megoldást?
Features of the first 4 weeks and First Feature of week 5.