Implement SetWorkingDirectory method with OTK API integration: - GetCurrentDirectory() to retrieve current path - ChangeDirectory() to switch working directory - Intelligent comparison: only changes if target differs from current - Path normalization for Windows (case-insensitive, backslash handling) - Comprehensive error handling with detailed result structure Also includes minor code cleanup in CreoManager.cpp formatting. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
48 lines
1.8 KiB
C++
48 lines
1.8 KiB
C++
#pragma once
|
|
|
|
// Creo OTK headers
|
|
#include <pfcGlobal.h>
|
|
#include <pfcSession.h>
|
|
#include <wfcSession.h>
|
|
#include <pfcExceptions.h>
|
|
|
|
// Standard library headers
|
|
#include <string>
|
|
#include <algorithm>
|
|
|
|
// Working directory change result structure
|
|
struct ChangeDirectoryResult {
|
|
bool success = false;
|
|
std::string original_directory; // Original working directory before operation
|
|
std::string target_directory; // Target directory requested by user
|
|
std::string current_directory; // Actual working directory after operation
|
|
bool directory_changed = false; // Whether directory was actually changed
|
|
std::string message; // Success message or informational text
|
|
std::string error_message; // Error details if operation failed
|
|
};
|
|
|
|
// Creo Utilities - Common utility functions for Creo operations
|
|
class CreoUtilities {
|
|
public:
|
|
// Set Creo working directory
|
|
// Only changes directory if target is different from current directory
|
|
// Parameters:
|
|
// target_directory - The desired working directory path
|
|
// Returns:
|
|
// ChangeDirectoryResult with detailed operation status
|
|
static ChangeDirectoryResult SetWorkingDirectory(const std::string& target_directory);
|
|
|
|
private:
|
|
// Private constructor - this is a static utility class
|
|
CreoUtilities() = delete;
|
|
~CreoUtilities() = delete;
|
|
CreoUtilities(const CreoUtilities&) = delete;
|
|
CreoUtilities& operator=(const CreoUtilities&) = delete;
|
|
|
|
// Helper methods for internal use
|
|
static std::string XStringToString(const xstring& xstr);
|
|
static xstring StringToXString(const std::string& str);
|
|
static std::string NormalizePath(const std::string& path);
|
|
static bool PathsAreEqual(const std::string& path1, const std::string& path2);
|
|
};
|