Skip to content

Commit

Permalink
Update getFileIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
naheedsa committed Sep 12, 2024
1 parent 12bd405 commit e5de53d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
17 changes: 10 additions & 7 deletions libs/indibase/indiccd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2560,7 +2560,10 @@ bool CCD::uploadFile(CCDChip * targetChip, const void * fitsData, size_t totalBy
FILE * fp = nullptr;

std::string prefix = UploadSettingsTP[UPLOAD_PREFIX].getText();
int maxIndex = getFileIndex(UploadSettingsTP[UPLOAD_DIR].getText(), UploadSettingsTP[UPLOAD_PREFIX].getText(),
std::string directory = UploadSettingsTP[UPLOAD_DIR].getText();


int maxIndex = getFileIndex(directory, UploadSettingsTP[UPLOAD_PREFIX].getText(),
targetChip->FitsBP[0].getFormat());

if (maxIndex < 0)
Expand Down Expand Up @@ -2944,7 +2947,7 @@ std::string regex_replace_compat(const std::string &input, const std::string &pa
return s.str();
}

int CCD::getFileIndex(const char * dir, const char * prefix, const char * ext)
int CCD::getFileIndex(const std::string & dir, const char * prefix, const char * ext)
{
INDI_UNUSED(ext);

Expand All @@ -2959,22 +2962,22 @@ int CCD::getFileIndex(const char * dir, const char * prefix, const char * ext)
// Create directory if does not exist
struct stat st;

if (stat(dir, &st) == -1)
if (stat(dir.c_str(), &st) == -1)
{
if (errno == ENOENT)
{
DEBUGF(Logger::DBG_DEBUG, "Creating directory %s...", dir);
LOGF_INFO("Creating directory %s...", dir.c_str());
if (INDI::mkpath(dir, 0755) == -1)
LOGF_ERROR("Error creating directory %s (%s)", dir, strerror(errno));
LOGF_ERROR("Error creating directory %s (%s)", dir.c_str(), strerror(errno));
}
else
{
LOGF_ERROR("Couldn't stat directory %s: %s", dir, strerror(errno));
LOGF_ERROR("Couldn't stat directory %s: %s", dir.c_str(), strerror(errno));
return -1;
}
}

dpdf = opendir(dir);
dpdf = opendir(dir.c_str());
if (dpdf != nullptr)
{
while ((epdf = readdir(dpdf)))
Expand Down
2 changes: 1 addition & 1 deletion libs/indibase/indiccd.h
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ class CCD : public DefaultDevice, GuiderInterface
///////////////////////////////////////////////////////////////////////////////
bool uploadFile(CCDChip * targetChip, const void * fitsData, size_t totalBytes, bool sendImage, bool saveImage);
void getMinMax(double * min, double * max, CCDChip * targetChip);
int getFileIndex(const char * dir, const char * prefix, const char * ext);
int getFileIndex(const std::string & dir, const char * prefix, const char * ext);
bool ExposureCompletePrivate(CCDChip * targetChip);

// Threading for Websocket
Expand Down
2 changes: 0 additions & 2 deletions libs/indibase/indiccdchip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,6 @@ void CCDChip::setBin(uint8_t hor, uint8_t ver)
void CCDChip::setMinMaxStep(const char *property, const char *element, double min, double max, double step,
bool sendToClient)
{
INumberVectorProperty *nvp = nullptr;

auto updateMinMaxStep = [element, min, max, step, sendToClient](INDI::PropertyNumber &oneProperty)
{
auto oneElement = oneProperty.findWidgetByName(element);
Expand Down

0 comments on commit e5de53d

Please sign in to comment.