Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
otb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Youssefi
otb
Commits
d7cdd90f
Commit
d7cdd90f
authored
18 years ago
by
Thomas Feuvrier
Browse files
Options
Downloads
Patches
Plain Diff
Modifications de l'appel aux fonctions systeme (opendir, etc...) pour etre portable sur Windows.
parent
665cf327
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Code/Common/otbSystem.cxx
+100
-0
100 additions, 0 deletions
Code/Common/otbSystem.cxx
Code/Common/otbSystem.h
+3
-0
3 additions, 0 deletions
Code/Common/otbSystem.h
Code/IO/otbGDALImageIO.cxx
+29
-6
29 additions, 6 deletions
Code/IO/otbGDALImageIO.cxx
with
132 additions
and
6 deletions
Code/Common/otbSystem.cxx
+
100
−
0
View file @
d7cdd90f
...
...
@@ -17,6 +17,26 @@
=========================================================================*/
#include
"otbSystem.h"
#include
<string.h>
// strdup
#if defined(WIN32) || defined(WIN32CE)
/*=====================================================================
WIN32 / MSVC++ implementation
*====================================================================*/
#ifndef WIN32CE
# include <io.h>
#else
# include <wce_io.h>
#endif
#else
/*=====================================================================
POSIX (Unix) implementation
*====================================================================*/
#include
<sys/types.h>
#include
<dirent.h>
#endif
namespace
otb
{
...
...
@@ -57,4 +77,84 @@ System::GetRootName( const std::string& filename )
return
(
filename
);
}
#if defined(WIN32) || defined(WIN32CE)
/*=====================================================================
WIN32 / MSVC++ implementation
*====================================================================*/
std
::
vector
<
std
::
string
>
System
::
Readdir
(
std
::
string
pszPath
)
{
struct
_finddata_t
c_file
;
long
hFile
;
std
::
vector
<
std
::
string
>
listFileFind
;
std
::
string
pszFileSpec
;
std
::
string
path
(
pszPath
);
if
(
pszPath
.
empty
()
==
true
)
path
=
"."
;
pszFileSpec
=
path
+
"
\\
*.*"
;
if
(
(
hFile
=
_findfirst
(
pszFileSpec
.
c_str
(),
&
c_file
))
!=
-
1L
)
{
do
{
listFileFind
.
push_back
(
c_file
.
name
);
}
while
(
_findnext
(
hFile
,
&
c_file
)
==
0
);
_findclose
(
hFile
);
}
return
listFileFind
;
}
#else
/*=====================================================================
POSIX (Unix) implementation
*====================================================================*/
/**
* Read names in a directory.
*
* This function abstracts access to directory contains. It returns a
* list of strings containing the names of files, and directories in this
* directory. The resulting string list becomes the responsibility of the
* application and should be freed with CSLDestroy() when no longer needed.
*
* Note that no error is issued via CPLError() if the directory path is
* invalid, though NULL is returned.
*
* @param pszPath the relative, or absolute path of a directory to read.
* @return The list of entries in the directory, or NULL if the directory
* doesn't exist.
*/
std
::
vector
<
std
::
string
>
System
::
Readdir
(
std
::
string
pszPath
)
{
DIR
*
hDir
;
std
::
vector
<
std
::
string
>
listFileFind
;
struct
dirent
*
psDirEntry
;
std
::
string
path
(
pszPath
);
if
(
pszPath
.
empty
()
==
true
)
path
=
"."
;
if
(
(
hDir
=
opendir
(
path
.
c_str
()))
!=
NULL
)
{
while
(
(
psDirEntry
=
readdir
(
hDir
))
!=
NULL
)
{
listFileFind
.
push_back
(
psDirEntry
->
d_name
);
}
closedir
(
hDir
);
}
return
listFileFind
;
}
#endif
}
This diff is collapsed.
Click to expand it.
Code/Common/otbSystem.h
+
3
−
0
View file @
d7cdd90f
...
...
@@ -19,6 +19,7 @@
#define _otbSystem_h
#include
<string>
#include
<vector>
namespace
otb
{
...
...
@@ -42,6 +43,8 @@ public:
/** Get the root name */
static
std
::
string
GetRootName
(
const
std
::
string
&
filename
);
/** Get list of file find in a directory */
static
std
::
vector
<
std
::
string
>
System
::
Readdir
(
std
::
string
pszPath
);
};
}
// namespace otb
...
...
This diff is collapsed.
Click to expand it.
Code/IO/otbGDALImageIO.cxx
+
29
−
6
View file @
d7cdd90f
...
...
@@ -38,13 +38,15 @@
#include
"itkMetaDataObject.h"
#include
<sys/types.h>
/*
#include <sys/types.h>
#include <dirent.h>
*/
// ROMAIN : Modification for VC++
#ifdef _MSC_VER
/*
#ifdef _MSC_VER
#define strcasecmp stricmp // _MICROSOFT_ VC++
#endif
*/
#include
"otbSystem.h"
...
...
@@ -92,8 +94,8 @@ GDALImageIO::~GDALImageIO()
bool
GDALImageIO
::
GetGdalReadImageFileName
(
const
char
*
filename
,
std
::
string
&
GdalFileName
)
{
DIR
*
ptr_repertoire
;
struct
dirent
*
cr_readdir
;
//
DIR *ptr_repertoire;
//
struct dirent *cr_readdir;
// std::string str_debut("DAT");
std
::
vector
<
std
::
string
>
listFileSearch
;
listFileSearch
.
push_back
(
"DAT_01.001"
);
// RADARSAT ou SAR_ERS2
...
...
@@ -104,7 +106,27 @@ bool GDALImageIO::GetGdalReadImageFileName( const char * filename, std::string &
bool
fic_trouve
(
false
);
// Si c'est un rpertoire, on regarde le contenu pour voir si c'est pas du RADARSAT, ERS
ptr_repertoire
=
opendir
(
filename
);
std
::
vector
<
std
::
string
>
listFileFind
;
listFileFind
=
System
::
Readdir
(
std
::
string
(
filename
));
if
(
listFileFind
.
empty
()
==
false
)
{
int
cpt
(
0
);
while
(
(
cpt
<
listFileFind
.
size
())
&&
(
fic_trouve
==
false
)
)
{
str_FileName
=
std
::
string
(
listFileFind
[
cpt
]);
for
(
int
i
=
0
;
i
<
listFileSearch
.
size
()
;
i
++
)
{
if
(
str_FileName
.
compare
(
listFileSearch
[
i
])
==
0
)
{
GdalFileName
=
std
::
string
(
filename
)
+
listFileSearch
[
i
];
fic_trouve
=
true
;
}
}
cpt
++
;
}
/* ptr_repertoire = opendir(filename);
if (ptr_repertoire != NULL)
{
while ((cr_readdir=readdir(ptr_repertoire))!=NULL && (fic_trouve==false) )
...
...
@@ -129,6 +151,7 @@ bool GDALImageIO::GetGdalReadImageFileName( const char * filename, std::string &
// fic_trouve=true;
//}
}
*/
}
else
{
...
...
@@ -150,7 +173,7 @@ bool GDALImageIO::GetGdalReadImageFileName( const char * filename, std::string &
}
otbMsgDevMacro
(
<<
"lFileNameGdal : "
<<
GdalFileName
.
c_str
());
otbMsgDevMacro
(
<<
"fic_trouve : "
<<
fic_trouve
);
closedir
(
ptr_repertoire
);
//
closedir(ptr_repertoire);
return
(
fic_trouve
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment