From d0cf4e8882a6d7e1ab5a10a1f23a613ca66d4954 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Sun, 19 Jan 2020 16:34:45 -0800 Subject: [PATCH] Change sim Filesystem.getDeployDirectory() to src/main/deploy (#2293) --- wpilibc/src/main/native/cpp/Filesystem.cpp | 12 +++++++++--- wpilibc/src/main/native/include/frc/Filesystem.h | 4 ++-- .../main/java/edu/wpi/first/wpilibj/Filesystem.java | 11 ++++++++--- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/wpilibc/src/main/native/cpp/Filesystem.cpp b/wpilibc/src/main/native/cpp/Filesystem.cpp index 1546050e9b..7d2ea1d4de 100644 --- a/wpilibc/src/main/native/cpp/Filesystem.cpp +++ b/wpilibc/src/main/native/cpp/Filesystem.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -18,7 +18,7 @@ void frc::filesystem::GetLaunchDirectory(wpi::SmallVectorImpl& result) { void frc::filesystem::GetOperatingDirectory( wpi::SmallVectorImpl& result) { - if (RobotBase::IsReal()) { + if constexpr (RobotBase::IsReal()) { wpi::sys::path::native("/home/lvuser", result); } else { frc::filesystem::GetLaunchDirectory(result); @@ -27,5 +27,11 @@ void frc::filesystem::GetOperatingDirectory( void frc::filesystem::GetDeployDirectory(wpi::SmallVectorImpl& result) { frc::filesystem::GetOperatingDirectory(result); - wpi::sys::path::append(result, "deploy"); + if constexpr (RobotBase::IsReal()) { + wpi::sys::path::append(result, "deploy"); + } else { + wpi::sys::path::append(result, "src"); + wpi::sys::path::append(result, "main"); + wpi::sys::path::append(result, "deploy"); + } } diff --git a/wpilibc/src/main/native/include/frc/Filesystem.h b/wpilibc/src/main/native/include/frc/Filesystem.h index b7ef3f1f5d..f196f7ad71 100644 --- a/wpilibc/src/main/native/include/frc/Filesystem.h +++ b/wpilibc/src/main/native/include/frc/Filesystem.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -34,7 +34,7 @@ void GetOperatingDirectory(wpi::SmallVectorImpl& result); * Obtains the deploy directory of the program, which is the remote location * src/main/deploy is deployed to by default. On the roboRIO, this is * /home/lvuser/deploy. In simulation, it is where the simulation was launched - * from, in the subdirectory "deploy" (`pwd`/deploy). + * from, in the subdirectory "src/main/deploy" (`pwd`/src/main/deploy). * * @param result The result of the operating directory lookup */ diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Filesystem.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Filesystem.java index cfefb6aa70..c1327aa046 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Filesystem.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Filesystem.java @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2008-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -48,11 +48,16 @@ public final class Filesystem { * Obtains the deploy directory of the program, which is the remote location * src/main/deploy is deployed to by default. On the roboRIO, this is * /home/lvuser/deploy. In simulation, it is where the simulation was launched - * from, in the subdirectory "deploy" (`pwd`/deploy). + * from, in the subdirectory "src/main/deploy" (`pwd`/src/main/deploy). * * @return The deploy directory */ public static File getDeployDirectory() { - return new File(getOperatingDirectory(), "deploy"); + if (RobotBase.isReal()) { + return new File(getOperatingDirectory(), "deploy"); + } else { + return new File(getOperatingDirectory(), "src" + File.separator + "main" + + File.separator + "deploy"); + } } }