project cleanup
This commit is contained in:
parent
fdfdd0ca93
commit
c22ca646a1
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
<mxfile host="app.diagrams.net" modified="2020-04-30T20:05:53.432Z" agent="5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.92 Safari/537.36" etag="5yI57G0tj_AETib5-SCg" version="13.0.4" type="device"><diagram id="C5RBs43oDa-KdzZeNtuy" name="Page-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+RMUwjJKHbS6KB+ZfiUOPt9ysdR372Ym9D2huSrDcBdVeY1B1dUC1aciZdROL6ejEnKmmlnEMOiNBlYfmQtGhiqCtAczdKCrjwwtgFEnbVU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gfDyUgKB2Qj+v0W85QjMXhHcnzUQ2q30lVm6aodD2XU3+q6bz2QWPaV73+GzxO3dtOiR701J+RVB3jfIfueTP73XESoLJfb1tn/wE=</diagram></mxfile>
|
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
<mxfile host="app.diagrams.net" modified="2020-04-30T20:05:53.432Z" agent="5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.92 Safari/537.36" etag="5yI57G0tj_AETib5-SCg" version="13.0.4" type="device"><diagram id="C5RBs43oDa-KdzZeNtuy" name="Page-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+RMUwjJKHbS6KB+ZfiUOPt9ysdR372Ym9D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X0AGbzCrOsRauNE3DQPnVmXy8L6mbWr1g/GCKslQq4IVtSR8tMdoS48hcGpvLHAs1mCdRThF3gfDyUgKB2Qj+v0W85QjMXhHcnzUQ2q30lVm6aodD2XU3+q6bz2QWPaV73+GzxO3dtOiR701J+RVB3jfIfueTP73XESoLJfb1tn/wE=</diagram></mxfile>
|
Binary file not shown.
|
@ -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
|
||||
{
|
|
@ -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 <list>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#include "refurbishingHddTool.h"
|
||||
#include "drive.h"
|
||||
#include "smart.h"
|
||||
|
||||
template <typename T, typename I>
|
||||
T* iterator_to_pointer(I i)
|
||||
template <typename T, typename I> 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_
|
||||
#endif // REHDD_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);
|
||||
|
|
@ -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)
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
*/
|
17
src/makefile
17
src/makefile
|
@ -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
|
|
@ -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 <Drive>* pvecDrives
|
||||
* \return void
|
||||
*/
|
||||
void App::searchDrives(vector <Drive>* pvecDrives)
|
||||
void reHDD::searchDrives(vector <Drive>* 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 <Drive>* pvecDrives)
|
|||
* \param pointer of vector <Drive>* pvecDrives
|
||||
* \return void
|
||||
*/
|
||||
void App::filterIgnoredDrives(vector <Drive>* pvecDrives)
|
||||
void reHDD::filterIgnoredDrives(vector <Drive>* pvecDrives)
|
||||
{
|
||||
string sDelimiter = ":";
|
||||
string sIgnoredDrivePath;
|
||||
|
@ -108,7 +108,7 @@ void App::filterIgnoredDrives(vector <Drive>* 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 <Drive>* pvecDrives)
|
|||
* \param pointer of vector <Drive>* pvecDrives
|
||||
* \return void
|
||||
*/
|
||||
void App::printDrives(vector <Drive>* pvecDrives)
|
||||
void reHDD::printDrives(vector <Drive>* pvecDrives)
|
||||
{
|
||||
cout << "------------DRIVES---------------" << endl;
|
||||
vector <Drive>::iterator it;
|
||||
|
@ -176,7 +176,7 @@ void App::printDrives(vector <Drive>* pvecDrives)
|
|||
* \param pointer of vector <Drive>* pvecDrives
|
||||
* \return void
|
||||
*/
|
||||
void App::addSMARTData(vector <Drive>* pvecDrives)
|
||||
void reHDD::addSMARTData(vector <Drive>* pvecDrives)
|
||||
{
|
||||
vector <Drive>::iterator it;
|
||||
for (it = pvecDrives->begin(); it != pvecDrives->end(); ++it)
|
Binary file not shown.
|
@ -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 <list>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
#endif // REFURBISHING_HDD_TOOL_H_
|
|
@ -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();
|
||||
|
||||
|
|
Loading…
Reference in New Issue