diff --git a/bin/release/reHDD b/bin/release/reHDD new file mode 100755 index 0000000..c401882 Binary files /dev/null and b/bin/release/reHDD differ diff --git a/src/blkid b/bin_util/blkid similarity index 100% rename from src/blkid rename to bin_util/blkid diff --git a/src/hwinfo b/bin_util/hwinfo similarity index 100% rename from src/hwinfo rename to bin_util/hwinfo diff --git a/src/smartctl b/bin_util/smartctl similarity index 100% rename from src/smartctl rename to bin_util/smartctl diff --git a/doc/diagrams/refurbishingHddTool.drawio b/doc/diagrams/refurbishingHddTool.drawio new file mode 100644 index 0000000..3667556 --- /dev/null +++ b/doc/diagrams/refurbishingHddTool.drawio @@ -0,0 +1 @@ +7VttU+o4FP41zOx+kGnTF+CjgKh3vczdxV31050Ioc1aGkyDiL9+kzalL6mXqlOCrDMONqdpSM85zzlPTkLLGiyezylc+t/JDAUtYMyeW9awBYBpA9ASf8Zsk0jcrpUIPIpnslMmmOAXJIWGlK7wDEWFjoyQgOFlUTglYYimrCCDlJJ1sducBMVvXUIPKYLJFAaq9AbPmJ9Iu6CTyS8Q9vz0m023l9xZwLSzfJPIhzOyzomss5Y1oISw5GrxPECBUF6ql5vLzU1w9eCef/szeoR/9/+4Hv9zkgw2essj21egKGTvHtpe/bx9PJsPfl6ML+l4fHUz8V5O5LtGbJPqC824+mSTUOYTj4QwOMukfUpW4QyJUQ3eyvpcEbLkQpML/0WMbaQvwBUjXOSzRSDv8regm1vxfNtJm3dyuLgxfC60NrKVzFVMsGTaHXqR/SKyolP0C2VIOzNIPcR+0c/aGp+jBpEF4pPkz1EUQIafipOD0n29bb/MRPxCWukNFpOTfILBSn7TD0o8ChcRnzdTzRkEHGnCbGsfMzRZwlgFaw72olHksIgy9PwO9arqkKNYHelj6wx9piHfws8hzzUa0phpqlr5/zq5VdPJTaParPvxckvx8hDxK+AGfM79e8qvPBZry4UL4cnhfST+XQyHYjoL/vFj0LJGVU+UfIH6ZHG/inYjZBv/hZnmJGQjuMCBsNsFCp4Qw1Mob0inMLn++jDAXsgbU24+R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rqs7Urh6C7Fm67ORXQfsi+y+C/Z2if51zX0AGbzCrOsRauNE3DQPnVmXy8L6mbWr1g/GCKslQq4IVtSR8tMdoS48hcGpvLHAs1mCdRThF3gfDyUgKB2Qj+v0W85QjMXhHcnzUQ2q30lVm6aodD2XU3+q6bz2QWPaV73+GzxO3dtOiR701J+RVB3jfIfueTP73XESoLJfb1tn/wE= \ No newline at end of file diff --git a/doc/diagrams/refurbishingHddTool.pdf b/doc/diagrams/refurbishingHddTool.pdf new file mode 100644 index 0000000..6989d9c Binary files /dev/null and b/doc/diagrams/refurbishingHddTool.pdf differ diff --git a/docu/diagrams/refurbishingHddTool.drawio b/docu/diagrams/refurbishingHddTool.drawio new file mode 100644 index 0000000..3667556 --- /dev/null +++ b/docu/diagrams/refurbishingHddTool.drawio @@ -0,0 +1 @@ +7VttU+o4FP41zOx+kGnTF+CjgKh3vczdxV31050Ioc1aGkyDiL9+kzalL6mXqlOCrDMONqdpSM85zzlPTkLLGiyezylc+t/JDAUtYMyeW9awBYBpA9ASf8Zsk0jcrpUIPIpnslMmmOAXJIWGlK7wDEWFjoyQgOFlUTglYYimrCCDlJJ1sducBMVvXUIPKYLJFAaq9AbPmJ9Iu6CTyS8Q9vz0m023l9xZwLSzfJPIhzOyzomss5Y1oISw5GrxPECBUF6ql5vLzU1w9eCef/szeoR/9/+4Hv9zkgw2essj21egKGTvHtpe/bx9PJsPfl6ML+l4fHUz8V5O5LtGbJPqC824+mSTUOYTj4QwOMukfUpW4QyJUQ3eyvpcEbLkQpML/0WMbaQvwBUjXOSzRSDv8regm1vxfNtJm3dyuLgxfC60NrKVzFVMsGTaHXqR/SKyolP0C2VIOzNIPcR+0c/aGp+jBpEF4pPkz1EUQIafipOD0n29bb/MRPxCWukNFpOTfILBSn7TD0o8ChcRnzdTzRkEHGnCbGsfMzRZwlgFaw72olHksIgy9PwO9arqkKNYHelj6wx9piHfws8hzzUa0phpqlr5/zq5VdPJTaParPvxckvx8hDxK+AGfM79e8qvPBZry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75HfPtbh4ntR66r9oxTyV8YvmxDhNyoMxNetohp+ecyTvK9p8Ypk7dTXcthLlXTAPdHfy3p4H+pgrcEUCSJD3nsMXekUWKrqs7Urh6C7Fm67ORXQfsi+y+C/Z2if51zX0AGbzCrOsRauNE3DQPnVmXy8L6mbWr1g/GCKslQq4IVtSR8tMdoS48hcGpvLHAs1mCdRThF3gfDyUgKB2Qj+v0W85QjMXhHcnzUQ2q30lVm6aodD2XU3+q6bz2QWPaV73+GzxO3dtOiR701J+RVB3jfIfueTP73XESoLJfb1tn/wE= \ No newline at end of file diff --git a/docu/diagrams/refurbishingHddTool.pdf b/docu/diagrams/refurbishingHddTool.pdf new file mode 100644 index 0000000..6989d9c Binary files /dev/null and b/docu/diagrams/refurbishingHddTool.pdf differ diff --git a/src/ignoreDrives.conf b/ignoreDrives.conf similarity index 100% rename from src/ignoreDrives.conf rename to ignoreDrives.conf diff --git a/src/drive.h b/include/drive.h similarity index 88% rename from src/drive.h rename to include/drive.h index 3b331be..3d7f3b1 100644 --- a/src/drive.h +++ b/include/drive.h @@ -1,14 +1,14 @@ /** - * @file drive.h - * @brief represent physical drive - * @author hendrik schutter - * @date 01.05.2020 + * @file drive.h + * @brief represent physical drive + * @author hendrik schutter + * @date 01.05.2020 */ #ifndef DRIVE_H_ #define DRIVE_H_ -#include "refurbishingHddTool.h" +#include "reHDD.h" class Drive { diff --git a/src/app.h b/include/reHDD.h similarity index 51% rename from src/app.h rename to include/reHDD.h index f4e891d..e0ba8bd 100644 --- a/src/app.h +++ b/include/reHDD.h @@ -1,29 +1,36 @@ /** - * @file app.h - * @brief app logic - * @author hendrik schutter - * @date 01.05.2020 + * @file reHDD.h + * @brief represent + * @author hendrik schutter + * @date 01.05.2020 */ -#ifndef APP_H_ -#define APP_H_ +#ifndef REHDD_H_ +#define REHDD_H_ + +#include +#include +#include +#include +#include +#include + +using namespace std; -#include "refurbishingHddTool.h" #include "drive.h" #include "smart.h" -template -T* iterator_to_pointer(I i) +template T* iterator_to_pointer(I i) { return (&(*i)); } -class App +class reHDD { protected: public: - App(void); + reHDD(void); void app_logic(); private: @@ -37,4 +44,4 @@ private: }; -#endif // APP_H_ \ No newline at end of file +#endif // REHDD_H_ \ No newline at end of file diff --git a/src/smart.h b/include/smart.h similarity index 82% rename from src/smart.h rename to include/smart.h index 50ee1fa..99e6cca 100644 --- a/src/smart.h +++ b/include/smart.h @@ -1,22 +1,19 @@ /** - * @file smart.h - * @brief read S.M.A.R.T values - * @author hendrik schutter - * @date 01.05.2020 + * @file smart.h + * @brief read S.M.A.R.T values + * @author hendrik schutter + * @date 01.05.2020 */ #ifndef SMART_H_ #define SMART_H_ -#include "refurbishingHddTool.h" -#include "drive.h" - +#include "reHDD.h" class SMART { protected: - public: static void readSMARTData(Drive* drive); diff --git a/makefile b/makefile new file mode 100644 index 0000000..ea15fdd --- /dev/null +++ b/makefile @@ -0,0 +1,224 @@ +#### PROJECT SETTINGS #### +# The name of the executable to be created +BIN_NAME := reHDD +# Compiler used +CXX ?= g++ +# Extension of source files used in the project +SRC_EXT = cpp +# Path to the source directory, relative to the makefile +SRC_PATH = src +# Space-separated pkg-config libraries used by this project +LIBS = +# General compiler flags +COMPILE_FLAGS = -std=c++11 -Wall -Wextra -g +# Additional release-specific flags +RCOMPILE_FLAGS = -D NDEBUG +# Additional debug-specific flags +DCOMPILE_FLAGS = -D DEBUG +# Add additional include paths +INCLUDES = include +# General linker settings +LINK_FLAGS = +# Additional release-specific linker settings +RLINK_FLAGS = +# Additional debug-specific linker settings +DLINK_FLAGS = +# Destination directory, like a jail or mounted system +DESTDIR = / +# Install path (bin/ is appended automatically) +INSTALL_PREFIX = usr/local +#### END PROJECT SETTINGS #### + +# Optionally you may move the section above to a separate config.mk file, and +# uncomment the line below +# include config.mk + +# Generally should not need to edit below this line + +# Obtains the OS type, either 'Darwin' (OS X) or 'Linux' +UNAME_S:=$(shell uname -s) + +# Function used to check variables. Use on the command line: +# make print-VARNAME +# Useful for debugging and adding features +print-%: ; @echo $*=$($*) + +# Shell used in this makefile +# bash is used for 'echo -en' +SHELL = /bin/bash +# Clear built-in rules +.SUFFIXES: +# Programs for installation +INSTALL = install +INSTALL_PROGRAM = $(INSTALL) +INSTALL_DATA = $(INSTALL) -m 644 + +# Append pkg-config specific libraries if need be +ifneq ($(LIBS),) + COMPILE_FLAGS += $(shell pkg-config --cflags $(LIBS)) + LINK_FLAGS += $(shell pkg-config --libs $(LIBS)) +endif + +# Verbose option, to output compile and link commands +export V := false +export CMD_PREFIX := @ +ifeq ($(V),true) + CMD_PREFIX := +endif + +# Combine compiler and linker flags +release: export CXXFLAGS := $(CXXFLAGS) $(COMPILE_FLAGS) $(RCOMPILE_FLAGS) +release: export LDFLAGS := $(LDFLAGS) $(LINK_FLAGS) $(RLINK_FLAGS) +debug: export CXXFLAGS := $(CXXFLAGS) $(COMPILE_FLAGS) $(DCOMPILE_FLAGS) +debug: export LDFLAGS := $(LDFLAGS) $(LINK_FLAGS) $(DLINK_FLAGS) + +# Build and output paths +release: export BUILD_PATH := build/release +release: export BIN_PATH := bin/release +debug: export BUILD_PATH := build/debug +debug: export BIN_PATH := bin/debug +install: export BIN_PATH := bin/release + +# Find all source files in the source directory, sorted by most +# recently modified +ifeq ($(UNAME_S),Darwin) + SOURCES = $(shell find $(SRC_PATH) -name '*.$(SRC_EXT)' | sort -k 1nr | cut -f2-) +else + SOURCES = $(shell find $(SRC_PATH) -name '*.$(SRC_EXT)' -printf '%T@\t%p\n' \ + | sort -k 1nr | cut -f2-) +endif + +# fallback in case the above fails +rwildcard = $(foreach d, $(wildcard $1*), $(call rwildcard,$d/,$2) \ + $(filter $(subst *,%,$2), $d)) +ifeq ($(SOURCES),) + SOURCES := $(call rwildcard, $(SRC_PATH), *.$(SRC_EXT)) +endif + +# Set the object file names, with the source directory stripped +# from the path, and the build path prepended in its place +OBJECTS = $(SOURCES:$(SRC_PATH)/%.$(SRC_EXT)=$(BUILD_PATH)/%.o) +# Set the dependency files that will be used to add header dependencies +DEPS = $(OBJECTS:.o=.d) + +# Macros for timing compilation +ifeq ($(UNAME_S),Darwin) + CUR_TIME = awk 'BEGIN{srand(); print srand()}' + TIME_FILE = $(dir $@).$(notdir $@)_time + START_TIME = $(CUR_TIME) > $(TIME_FILE) + END_TIME = read st < $(TIME_FILE) ; \ + $(RM) $(TIME_FILE) ; \ + st=$$((`$(CUR_TIME)` - $$st)) ; \ + echo $$st +else + TIME_FILE = $(dir $@).$(notdir $@)_time + START_TIME = date '+%s' > $(TIME_FILE) + END_TIME = read st < $(TIME_FILE) ; \ + $(RM) $(TIME_FILE) ; \ + st=$$((`date '+%s'` - $$st - 86400)) ; \ + echo `date -u -d @$$st '+%H:%M:%S'` +endif + +# Version macros +# Comment/remove this section to remove versioning +USE_VERSION := false +# If this isn't a git repo or the repo has no tags, git describe will return non-zero +ifeq ($(shell git describe > /dev/null 2>&1 ; echo $$?), 0) + USE_VERSION := true + VERSION := $(shell git describe --tags --long --dirty --always | \ + sed 's/v\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)-\?.*-\([0-9]*\)-\(.*\)/\1 \2 \3 \4 \5/g') + VERSION_MAJOR := $(word 1, $(VERSION)) + VERSION_MINOR := $(word 2, $(VERSION)) + VERSION_PATCH := $(word 3, $(VERSION)) + VERSION_REVISION := $(word 4, $(VERSION)) + VERSION_HASH := $(word 5, $(VERSION)) + VERSION_STRING := \ + "$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH).$(VERSION_REVISION)-$(VERSION_HASH)" + override CXXFLAGS := $(CXXFLAGS) \ + -D VERSION_MAJOR=$(VERSION_MAJOR) \ + -D VERSION_MINOR=$(VERSION_MINOR) \ + -D VERSION_PATCH=$(VERSION_PATCH) \ + -D VERSION_REVISION=$(VERSION_REVISION) \ + -D VERSION_HASH=\"$(VERSION_HASH)\" +endif + +# Standard, non-optimized release build +.PHONY: release +release: dirs +ifeq ($(USE_VERSION), true) + @echo "Beginning release build v$(VERSION_STRING)" +else + @echo "Beginning release build" +endif + @$(START_TIME) + @$(MAKE) all --no-print-directory + @echo -n "Total build time: " + @$(END_TIME) + +# Debug build for gdb debugging +.PHONY: debug +debug: dirs +ifeq ($(USE_VERSION), true) + @echo "Beginning debug build v$(VERSION_STRING)" +else + @echo "Beginning debug build" +endif + @$(START_TIME) + @$(MAKE) all --no-print-directory + @echo -n "Total build time: " + @$(END_TIME) + +# Create the directories used in the build +.PHONY: dirs +dirs: + @echo "Creating directories" + @mkdir -p $(dir $(OBJECTS)) + @mkdir -p $(BIN_PATH) + +# Installs to the set path +.PHONY: install +install: + @echo "Installing to $(DESTDIR)$(INSTALL_PREFIX)/bin" + @$(INSTALL_PROGRAM) $(BIN_PATH)/$(BIN_NAME) $(DESTDIR)$(INSTALL_PREFIX)/bin + +# Uninstalls the program +.PHONY: uninstall +uninstall: + @echo "Removing $(DESTDIR)$(INSTALL_PREFIX)/bin/$(BIN_NAME)" + @$(RM) $(DESTDIR)$(INSTALL_PREFIX)/bin/$(BIN_NAME) + +# Removes all build files +.PHONY: clean +clean: + @echo "Deleting $(BIN_NAME) symlink" + @$(RM) $(BIN_NAME) + @echo "Deleting directories" + @$(RM) -r build + @$(RM) -r bin + +# Main rule, checks the executable and symlinks to the output +all: $(BIN_PATH)/$(BIN_NAME) + @echo "Making symlink: $(BIN_NAME) -> $<" + @$(RM) $(BIN_NAME) + @ln -s $(BIN_PATH)/$(BIN_NAME) $(BIN_NAME) + +# Link the executable +$(BIN_PATH)/$(BIN_NAME): $(OBJECTS) + @echo "Linking: $@" + @$(START_TIME) + $(CMD_PREFIX)$(CXX) $(OBJECTS) $(LDFLAGS) -o $@ + @echo -en "\t Link time: " + @$(END_TIME) + +# Add dependency files, if they exist +-include $(DEPS) + +# Source file rules +# After the first compilation they will be joined with the rules from the +# dependency files to provide header dependencies +$(BUILD_PATH)/%.o: $(SRC_PATH)/%.$(SRC_EXT) + @echo "Compiling: $< -> $@" + @$(START_TIME) + $(CMD_PREFIX)$(CXX) $(CXXFLAGS) $(INCLUDES) -MP -MMD -c $< -o $@ + @echo -en "\t Compile time: " + @$(END_TIME) diff --git a/reHDD b/reHDD new file mode 120000 index 0000000..2f2265d --- /dev/null +++ b/reHDD @@ -0,0 +1 @@ +bin/release/reHDD \ No newline at end of file diff --git a/src/drive.cpp b/src/drive.cpp index aabc55b..c597b1e 100644 --- a/src/drive.cpp +++ b/src/drive.cpp @@ -1,11 +1,11 @@ /** - * @file drive.cpp - * @brief represent physical drive - * @author hendrik schutter - * @date 01.05.2020 + * @file drive.cpp + * @brief represent physical drive + * @author hendrik schutter + * @date 01.05.2020 */ -#include "drive.h" +#include "../include/reHDD.h" string Drive::getPath(void) { diff --git a/src/main.cpp b/src/main.cpp index 35e4398..4978cb8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,9 +5,7 @@ * @date 01.05.2020 */ -#include "refurbishingHddTool.h" -#include "app.h" - +#include "../include/reHDD.h" /** * \brief app entry point @@ -18,8 +16,7 @@ int main(void) { cout << "refurbishingHddTool" << endl; - App* app = new App(); + reHDD* app = new reHDD(); app->app_logic(); - return EXIT_SUCCESS; } \ No newline at end of file diff --git a/src/mainTest.cpp b/src/mainTest.cpp deleted file mode 100644 index 330705e..0000000 --- a/src/mainTest.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - -deviceData getDeviceData(string path) { - - - - struct deviceData hdd; - - - - size_t len = 0; //lenght of found line - char * cLine = NULL; //found line - - string comand = ("./smartctl -a " + path); - const char *cComand = comand.c_str(); - - FILE* outputfileSmart = popen(cComand, "r"); - - - - while ((getline(&cLine, &len, outputfileSmart)) != -1) { - - - - string line = string(cLine); - - cout << line << "XYZ\n"; - - string search ("Device Model:"); - - size_t found = line.find(search); - - if (found!=string::npos) { - - int lenght = line.length(); //lenght of line - - - string str3 (":"); - found = line.find(str3); - - cout << "Found1: " << found << endl; - - for(int i = (found+1); i < lenght; i++) { - - if(line[i] != ' ') { - cout << i << endl; - found = i; - break; - } - - } - - - - string model = line.substr (found, lenght); - - model = removeLastNewLine(model); - - cout << model << endl; - - return hdd; - - } - - } - - fclose(outputfileSmart); - - return hdd; - -} - - - -string removeLastNewLine(string s) { - if (!s.empty() && s[s.length()-1] == '\n') { - s.erase(s.length()-1); - } - return s; -} -*/ \ No newline at end of file diff --git a/src/makefile b/src/makefile deleted file mode 100644 index 2da7fa0..0000000 --- a/src/makefile +++ /dev/null @@ -1,17 +0,0 @@ -reHDD: main.o app.o drive.o smart.o - g++ -Wall -o reHDD main.o app.o drive.o smart.o - -main.o: main.cpp - g++ -c main.cpp - -app.o: app.cpp - g++ -c app.cpp - -drive.o: drive.cpp - g++ -c drive.cpp - -smart.o: smart.cpp - g++ -c smart.cpp - -clean : - rm reHDD main.o app.o drive.o smart.o diff --git a/src/reHDD b/src/reHDD deleted file mode 100755 index 3cedd21..0000000 Binary files a/src/reHDD and /dev/null differ diff --git a/src/app.cpp b/src/reHDD.cpp similarity index 91% rename from src/app.cpp rename to src/reHDD.cpp index cc39b93..756f95a 100644 --- a/src/app.cpp +++ b/src/reHDD.cpp @@ -1,18 +1,18 @@ /** - * @file app.cpp - * @brief app logic - * @author hendrik schutter - * @date 01.05.2020 + * @file reHDD.cpp + * @brief app logic + * @author hendrik schutter + * @date 01.05.2020 */ -#include "app.h" +#include "../include/reHDD.h" /** * \brief app constructor * \param void * \return instance of App */ -App::App(void) +reHDD::reHDD(void) { cout << "created app" << endl; } @@ -22,7 +22,7 @@ App::App(void) * \param void * \return void */ -void App::app_logic(void) +void reHDD::app_logic(void) { cout << "app logic" << endl; @@ -37,13 +37,13 @@ void App::app_logic(void) * \param pointer of vector * pvecDrives * \return void */ -void App::searchDrives(vector * pvecDrives) +void reHDD::searchDrives(vector * pvecDrives) { cout << "search drives ..." << endl; char * cLine = NULL; size_t len = 0; - FILE* outputfileHwinfo = popen("./hwinfo --short --disk", "r"); + FILE* outputfileHwinfo = popen("./bin_util/hwinfo --short --disk", "r"); if (outputfileHwinfo == NULL) { @@ -66,7 +66,7 @@ void App::searchDrives(vector * pvecDrives) * \param pointer of vector * pvecDrives * \return void */ -void App::filterIgnoredDrives(vector * pvecDrives) +void reHDD::filterIgnoredDrives(vector * pvecDrives) { string sDelimiter = ":"; string sIgnoredDrivePath; @@ -108,7 +108,7 @@ void App::filterIgnoredDrives(vector * pvecDrives) // cout << "Same drive path found" << endl; char * cLine = NULL; size_t len = 0; - string sCMD = "./blkid "; + string sCMD = "./bin_util/blkid "; sCMD.append(it->getPath()); // cout << "cmd: " << sCMD << endl; FILE* outputfileBlkid = popen(sCMD.c_str(), "r"); //get UUID from drive @@ -152,7 +152,7 @@ void App::filterIgnoredDrives(vector * pvecDrives) * \param pointer of vector * pvecDrives * \return void */ -void App::printDrives(vector * pvecDrives) +void reHDD::printDrives(vector * pvecDrives) { cout << "------------DRIVES---------------" << endl; vector ::iterator it; @@ -176,7 +176,7 @@ void App::printDrives(vector * pvecDrives) * \param pointer of vector * pvecDrives * \return void */ -void App::addSMARTData(vector * pvecDrives) +void reHDD::addSMARTData(vector * pvecDrives) { vector ::iterator it; for (it = pvecDrives->begin(); it != pvecDrives->end(); ++it) diff --git a/src/refurbishingHddTool b/src/refurbishingHddTool deleted file mode 100755 index 953e709..0000000 Binary files a/src/refurbishingHddTool and /dev/null differ diff --git a/src/refurbishingHddTool.h b/src/refurbishingHddTool.h deleted file mode 100644 index 246dd1c..0000000 --- a/src/refurbishingHddTool.h +++ /dev/null @@ -1,21 +0,0 @@ -/** - * @file refurbishingHddTool.h - * @brief represent - * @author hendrik schutter - * @date 01.05.2020 - */ - -#ifndef REFURBISHING_HDD_TOOL_H_ -#define REFURBISHING_HDD_TOOL_H_ - -#include -#include -#include -#include -#include -#include - -using namespace std; - - -#endif // REFURBISHING_HDD_TOOL_H_ \ No newline at end of file diff --git a/src/smart.cpp b/src/smart.cpp index d0da3f5..5350ed2 100644 --- a/src/smart.cpp +++ b/src/smart.cpp @@ -1,11 +1,11 @@ /** - * @file smart.cpp - * @brief read S.M.A.R.T values - * @author hendrik schutter - * @date 01.05.2020 + * @file smart.cpp + * @brief read S.M.A.R.T values + * @author hendrik schutter + * @date 01.05.2020 */ -#include "smart.h" +#include "../include/reHDD.h" string SMART::modelFamily; string SMART::modelName; @@ -33,7 +33,7 @@ void SMART::readSMARTData(Drive* drive) size_t len = 0; //lenght of found line char* cLine = NULL; //found line - string sCMD = ("./smartctl --json -a "); + string sCMD = ("./bin_util/smartctl --json -a "); sCMD.append(drive->getPath()); const char* cpComand = sCMD.c_str();