Skip to content

Fixed linux gcc compilation errors #11

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion L2DFileDialog/src/L2DFileDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,11 @@ namespace FileDialog {
std::time_t tt = std::chrono::system_clock::to_time_t(st);

std::tm mt;
#ifdef _WIN32
localtime_s(&mt, &tt);
#else
localtime_r(&tt, &mt);
#endif
std::stringstream ss;
ss << std::put_time(&mt, "%F %R");

Expand Down Expand Up @@ -275,7 +279,11 @@ namespace FileDialog {
ImGui::InputText("##newfolder", new_folder_name, sizeof(new_folder_name));
if (ImGui::Button("Create##1")) {
if (strlen(new_folder_name) <= 0) {
#ifdef _WIN32
strcpy_s(new_folder_error, "Folder name can't be empty");
#else
strcpy(new_folder_error, "Folder name can't be empty");
#endif
}
else {
std::string new_file_path = file_dialog_current_path + (file_dialog_current_path.back() == '\\' ? "" : "\\") + new_folder_name;
Expand All @@ -285,8 +293,13 @@ namespace FileDialog {
}
ImGui::SameLine();
if (ImGui::Button("Cancel##1")) {
#ifdef _WIN32
strcpy_s(new_folder_name, "");
strcpy_s(new_folder_error, "");
#else
strcpy(new_folder_name, "");
strcpy(new_folder_error, "");
#endif
ImGui::CloseCurrentPopup();
}
ImGui::TextColored(ImColor(1.0f, 0.0f, 0.2f, 1.0f), new_folder_error);
Expand Down Expand Up @@ -316,7 +329,11 @@ namespace FileDialog {
file_dialog_file_select_index = 0;
file_dialog_folder_select_index = 0;
file_dialog_current_file = "";
#ifdef _WIN32
strcpy_s(file_dialog_error, "");
#else
strcpy(file_dialog_error, "");
#endif
initial_path_set = false;
file_dialog_open = false;
};
Expand All @@ -328,23 +345,41 @@ namespace FileDialog {
if (ImGui::Button("Choose")) {
if (type == FileDialogType::SelectFolder) {
if (file_dialog_current_folder == "") {
#ifdef _WIN32
strcpy_s(file_dialog_error, "Error: You must select a folder!");
#else
strcpy(file_dialog_error, "Error: You must select a folder!");
#endif
}
else {
auto path = file_dialog_current_path + (file_dialog_current_path.back() == '\\' ? "" : "\\") + file_dialog_current_file;
#ifdef _WIN32
strcpy_s(buffer, path.length() + 1, path.c_str());
strcpy_s(file_dialog_error, "");
#else
strcpy(buffer, path.c_str());
strcpy(file_dialog_error, "");
#endif
reset_everything();
}
}
else if (type == FileDialogType::OpenFile) {
if (file_dialog_current_file == "") {
#ifdef _WIN32
strcpy_s(file_dialog_error, "Error: You must select a file!");
#else
strcpy(file_dialog_error, "Error: You must select a file!");
#endif
}
else {
auto path = file_dialog_current_path + (file_dialog_current_path.back() == '\\' ? "" : "\\") + file_dialog_current_file;
#ifdef _WIN32
strcpy_s(buffer, path.length() + 1, path.c_str());
strcpy_s(file_dialog_error, "");
#else
strcpy(buffer, path.c_str());
strcpy(file_dialog_error, "");
#endif
reset_everything();
}
}
Expand All @@ -364,4 +399,3 @@ namespace FileDialog {
}

}

4 changes: 2 additions & 2 deletions L2DFileDialog/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ int main(int, char**)


// L2DFileDialog code goes here.
static char* file_dialog_buffer = new char[500];
static char* file_dialog_buffer;
static char path1[500] = "";
static char path2[500] = "";
static char path3[500] = "";
Expand Down Expand Up @@ -251,4 +251,4 @@ void set_style() {
colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f);
colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.35f);

}
}