<commit_before>//
// Copyright (C) 2006 SIPez LLC.
// Licensed to SIPfoundry under a Contributor Agreement.
//
// Copyright (C) 2004-2006 SIPfoundry Inc.
// Licensed by SIPfoundry under the LGPL license.
//
// Copyright (C) 2004-2006 Pingtel Corp.  All rights reserved.
// Licensed to SIPfoundry under a Contributor Agreement.
//
// $$
///////////////////////////////////////////////////////////////////////////////


// SYSTEM INCLUDES
#ifndef WINCE
#   include <io.h>
#endif

// APPLICATION INCLUDES
#include "os/OsFS.h"

// EXTERNAL FUNCTIONS
// EXTERNAL VARIABLES
// CONSTANTS
// STATIC VARIABLE INITIALIZATIONS

/* //////////////////////////// PUBLIC //////////////////////////////////// */

/* ============================ CREATORS ================================== */

// Constructor


OsFileIteratorWnt::OsFileIteratorWnt(const OsPathWnt& pathname) :
OsFileIteratorBase(pathname)
{
}

// Override this function for releasing mSearchHandle.
void OsFileIteratorWnt::Release()
{
    OsFileIteratorBase::Release(); 

    if (mSearchHandle != INVALID_HANDLE)
    {
        _findclose(mSearchHandle);
        mSearchHandle = INVALID_HANDLE;
    }

}

// Destructor
OsFileIteratorWnt::~OsFileIteratorWnt()
{
    Release();
}

/* ============================ MANIPULATORS ============================== */


/* ============================ ACCESSORS ================================= */
/*

/* ============================ INQUIRY =================================== */


/* //////////////////////////// PROTECTED ///////////////////////////////// */

/* //////////////////////////// PRIVATE /////////////////////////////////// */
OsFileIteratorWnt::OsFileIteratorWnt() 
{
}



OsStatus OsFileIteratorWnt::getFirstEntryName(UtlString &name, OsFileType &type)
{
    OsStatus stat = OS_FILE_NOT_FOUND;
    
    name = "";
    UtlString fullPath = mFullSearchSpec;    
    fullPath += "*";

    _finddata_t FileInfo;
        
    mSearchHandle = _findfirst(fullPath.data(),&FileInfo);
    if (mSearchHandle != -1)
    {
        name = FileInfo.name;
        stat = OS_SUCCESS;
    }
    else
        stat = OS_FILE_NOT_FOUND;
    
    if (FileInfo.attrib & _A_SUBDIR)
        type = DIRECTORIES;
    else
        type = FILES;

    return stat;
}



OsStatus OsFileIteratorWnt::getNextEntryName(UtlString &name, OsFileType &type)
{
    OsStatus stat = OS_FILE_NOT_FOUND;
    
    name = "";

    _finddata_t FileInfo;
    int retcode = _findnext(mSearchHandle,&FileInfo);
    if (retcode != -1)
    {
        stat = OS_SUCCESS;
        name = FileInfo.name;
    }

    if (FileInfo.attrib & _A_SUBDIR)
        type = DIRECTORIES;
    else
        type = FILES;


    return stat;
}

/* ============================ FUNCTIONS ================================= */


<commit_msg>Fix uninitialized memory usage in OsFileIteratorWnt: access FileInfo structure only if files was found.<commit_after>//
// Copyright (C) 2006-2007 SIPez LLC.
// Licensed to SIPfoundry under a Contributor Agreement.
//
// Copyright (C) 2004-2007 SIPfoundry Inc.
// Licensed by SIPfoundry under the LGPL license.
//
// Copyright (C) 2004-2006 Pingtel Corp.  All rights reserved.
// Licensed to SIPfoundry under a Contributor Agreement.
//
// $$
///////////////////////////////////////////////////////////////////////////////


// SYSTEM INCLUDES
#ifndef WINCE
#   include <io.h>
#endif

// APPLICATION INCLUDES
#include "os/OsFS.h"

// EXTERNAL FUNCTIONS
// EXTERNAL VARIABLES
// CONSTANTS
// STATIC VARIABLE INITIALIZATIONS

/* //////////////////////////// PUBLIC //////////////////////////////////// */

/* ============================ CREATORS ================================== */

// Constructor


OsFileIteratorWnt::OsFileIteratorWnt(const OsPathWnt& pathname) :
OsFileIteratorBase(pathname)
{
}

// Override this function for releasing mSearchHandle.
void OsFileIteratorWnt::Release()
{
    OsFileIteratorBase::Release(); 

    if (mSearchHandle != INVALID_HANDLE)
    {
        _findclose(mSearchHandle);
        mSearchHandle = INVALID_HANDLE;
    }

}

// Destructor
OsFileIteratorWnt::~OsFileIteratorWnt()
{
    Release();
}

/* ============================ MANIPULATORS ============================== */


/* ============================ ACCESSORS ================================= */
/*

/* ============================ INQUIRY =================================== */


/* //////////////////////////// PROTECTED ///////////////////////////////// */

/* //////////////////////////// PRIVATE /////////////////////////////////// */
OsFileIteratorWnt::OsFileIteratorWnt() 
{
}



OsStatus OsFileIteratorWnt::getFirstEntryName(UtlString &name, OsFileType &type)
{
    OsStatus stat = OS_FILE_NOT_FOUND;
    
    name = "";
    UtlString fullPath = mFullSearchSpec;    
    fullPath += "*";

    _finddata_t FileInfo;
        
    mSearchHandle = _findfirst(fullPath.data(),&FileInfo);
    if (mSearchHandle != -1)
    {
        name = FileInfo.name;
        stat = OS_SUCCESS;

        if (FileInfo.attrib & _A_SUBDIR)
           type = DIRECTORIES;
        else
           type = FILES;
    }
    else
    {
        stat = OS_FILE_NOT_FOUND;
    }

    return stat;
}



OsStatus OsFileIteratorWnt::getNextEntryName(UtlString &name, OsFileType &type)
{
    OsStatus stat = OS_FILE_NOT_FOUND;
    
    name = "";

    _finddata_t FileInfo;
    int retcode = _findnext(mSearchHandle,&FileInfo);
    if (retcode != -1)
    {
        stat = OS_SUCCESS;
        name = FileInfo.name;

        if (FileInfo.attrib & _A_SUBDIR)
           type = DIRECTORIES;
        else
           type = FILES;
    }


    return stat;
}

/* ============================ FUNCTIONS ================================= */



{'fraction_non_alphanumeric': 0.29142454657510125, 'fraction_numerical': 0.008452192287374538, 'mean_word_length': 2.169642857142857, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3303826', 'n_tokens_mistral': 1737, 'n_tokens_neox': 1608, 'n_words': 331}