Example #1
0
// GetExtension():
//  Returns the extension part of the path, which is the part of
//  the file part after the last '.'.  If there is no extension,
//  or no file part, the output will be an empty string.
char * DirStrings::GetExtension( char *output, const char *path ) {
  if( !path )
    path = output;

  char *file = HasFile( path );
  if( file == NULL ) {                            // No file part; return an empty string
    output[0] = '\0';
    return output;
  }

  char * dot = strrchr(path, '.');
  if( !dot ) {                                    // No extension; return an empty string
    output[0] = '\0';
    return output;
  }

  if( dot == path )                               // Entire output is extension
    if( path != output ) {
      strcpy( output, path );

    return output;
  }

  strcpy( output, dot );                          // Extension is part of file part; copy the extension into the output buffer
  return output;
}
Example #2
0
void
Project::MakeFileDirty(SourceFile *file)
{
	if  (!file || !HasFile(GetPathForFile(file).GetFullPath()))
		return;
	
	if (!fDirtyFiles.HasItem(file))
		fDirtyFiles.AddItem(file);
}
Example #3
0
//--------------------------------------------------------------------------
VeBinaryIStreamPtr VeAssetPath::OpenSync(
	const VeChar8* pcFile) const noexcept
{
	if (HasFile(pcFile))
	{
		VeChar8 acBuffer[VE_MAX_PATH_LEN];
		PATH_CAT(acBuffer, m_kPath, pcFile);
		return VE_NEW VeAssetIStream(acBuffer);
	}
	return nullptr;
}
Example #4
0
// ChangeFile():
//  Changes the file of the input path.  If a file part
//  already exists, it is removed.  In either event, the new
//  file part will be at the end of the buffer.  Note that
//  the file part is assumed to include an extension, and any
//  old extension and/or file part will be removed.
char * DirStrings::ChangeFile( char *output, const char *new_file ) {
  if( !new_file )
    return output;

  char * old_file = HasFile( output );   // Eliminate any existing extensions
  if( old_file )
    old_file[0] = '\0';

  strcat( output, new_file );
  return output;
}
Example #5
0
// GetFilePart():
//  Returns the file part of the path.  This is everything after
//  the last / or \, or after the last : if there isn't a directory
//  slash.  If there are no slashes or colons, the entire buffer is
//  the path.  If the buffer ends in  a slash or colon, there is no
//  file part, and an empty buffer is returned.
char * DirStrings::GetFilePart(  char *output, const char *path ) {
  if( !path )
    path = output;

  char *filepart = HasFile( path );
  if( !filepart ) {                             // No file part; return an empty string
    output[0] = '\0';
    return output;
  }
  
  strcpy( output, filepart );
  return output;
}
Example #6
0
static sqlite3 *BrowseOpenDBByHWND(HWND hwnd, PROJECTITEM **returnProj)
{
    char *filname = (char*)SendMessage(hwnd, WM_FILENAME, 0, 0);
    PROJECTITEM *pj = HasFile(workArea, filname);
    while (pj && pj->type != PJ_PROJ)
        pj = pj->parent;
    if (!pj)
    {
        return NULL;
    }    
    *returnProj = pj;
    return BrowseDBOpen(pj);
}
int gxsURL::ParseDirectory(const gxString &url, gxString &path,
			   gxString &dir, gxString &file)
// Build the directory and filename components of the path.  
{
  gxString sbuf(url);
  const char *gxsHOSTNAME_ID = "://";
  path.Clear();
  dir.Clear();
  file.Clear();

  // 09/11/2006: Set the default protocol if not set
  SetDefaultProto(sbuf);

  // Identify where the host name starts in a URL
  int offset = sbuf.Find(gxsHOSTNAME_ID);

  // A URL Host Name was not found
  if(offset == -1) return 0;

  sbuf.DeleteAt(0, (offset+strlen(gxsHOSTNAME_ID)));
  sbuf.TrimLeadingSpaces();

  gxString dir_buf = sbuf;
  dir_buf.DeleteAfterIncluding("?");
  dir_buf.DeleteAfterIncluding("#");

  // 03/30/2009: Account for JS session IDs
  // Example: /switchsite.ds;jsessionid=54D3A5C9DC8A767DF64B3A377FB3EA8B
  dir_buf.DeleteAfterIncluding(";");

  offset = dir_buf.Find("/"); // Scan to the end of the host name
  if(offset != -1) { 
    // Remove everything before the host name
    sbuf.DeleteAt(0, offset);
  }
  else {
    path = "/";
    dir = "/";
    return 0; // No path specified in the url
  }

  // Remove everything following a trailing space
  offset = sbuf.Find(" "); 
  if(offset != -1) {
    sbuf.DeleteAt(offset, (sbuf.length() - offset));
  }
  path = sbuf;

  return HasFile(path, dir, file);
}
Example #8
0
PROJECTITEM *HasFile(PROJECTITEM *data, char *name)
{
    PROJECTITEM *rv = NULL;
    data = data->children;
    while (data && !rv)
    {
        if (data->type == PJ_FOLDER || data->type == PJ_PROJ)
            rv = HasFile(data, name);
        else if (data->type == PJ_FILE)
        {
            if (!stricmp(data->realName, name))
                rv = data;
        }
        data = data->next;
    }
    return rv;
}
Example #9
0
// GetFilePartOnly():
//  Returns the file part of the path without the extension.  This is
//  everything after the last / or \, or after the last : if there
//  isn't a directory slash, and everything before the last '.'.  If
//  there are no slashes, colons or dots, the entire buffer is
//  the file part.  If the buffer ends in  a slash or colon, there is no
//  file part, and an empty buffer is returned.
char * DirStrings::GetFilePartOnly(  char *output, const char *path ) {
  if( !path )
    path = output;

  char *filepart = HasFile( path );
  if( !filepart ) {                             // No file part; return an empty string
    output[0] = '\0';
    return output;
  }

  char *ext = HasExtension( output );           // Strip the extension, if any
  if( ext )
    ext[0] = '\0';

  strcpy( output, filepart );
  return output;
}
Example #10
0
// ChangeFileOnly():
//  Changes the file of the input path.  If a file part
//  already exists, it is removed.  In either event, the new
//  file part will be at the end of the buffer.  Note that
//  the only the file part is changed.  If there is an extension
//  in the original file part, it will be retained.  The new
//  file part is assumed to be just a file part, and is not
//  modified or checked in any wau.
char * DirStrings::ChangeFileOnly( char *output, const char *new_file ) {
  if( !new_file )
    return output;

  char * old_file = HasFile( output );   // Eliminate any existing file part...
  char * old_ext  = 0;
  char buffer[MAX_FILENAME_LENGTH];
  if( old_file ) {
    old_ext = HasExtension( old_file );  // ...but keep the extension
    if( old_ext ) {
      strcpy( buffer, old_ext );
      old_file[0] = '\0';
    }
  }

  strcat( output, new_file );
  if( old_ext )
    strcpy( output, buffer );

  return output;
}
Example #11
0
PROJECTITEM *AddFile(PROJECTITEM *data, char *name, BOOL automatic)
{
    PROJECTITEM *file;
    PROJECTITEM **ins;
    HTREEITEM pos = TVI_FIRST;
    char *p;
    if (file = HasFile(data, name))
        return file;
    p = strrchr(name, '\\');
    if (p)
        p ++;
    else
        p = name;
    if (data->type == PJ_PROJ && automatic)
    {
        if (!strnicmp(szInstallPath, name, strlen(szInstallPath)))
        {
            return NULL;
        }
        else
        {
            int i;
            for (i = 0; i < sizeof(extensionMap)/sizeof(extensionMap[0]); i++)
            {
                if (strlen(extensionMap[i][0]) < strlen(name) &&
                    !stricmp(name +strlen(name)- strlen(extensionMap[i][0]), extensionMap[i][0]))
                    {
                        data = CreateFolder(data, extensionMap[i][1], FALSE);
                        break;
                    }
            }
        }
    }
    ins = &data->children;
    while (*ins && (*ins)->type == PJ_FOLDER)
    {
        pos = (*ins)->hTreeItem;
        ins = &(*ins)->next;
    }
    while (*ins && stricmp((*ins)->displayName, p) < 0)
    {
        pos = (*ins)->hTreeItem;
        ins = &(*ins)->next;
    }
    file = RetrieveInternalDepend(name);
    if (!file)
        file = calloc(1, sizeof(PROJECTITEM));
    if (file)
    {
        file->type = PJ_FILE;
        file->parent = data;
        strcpy(file->realName, name);
        strcpy(file->displayName, p);
        
        file->next = *ins;
        *ins = file;
        TVInsertItem(prjTreeWindow, data->hTreeItem, pos, file);
        ExpandParents(file);
        MarkChanged(file, FALSE);
        ResAddItem(file);
    }
    return file;
}
int gxsURL::ParseDirectory(gxsURLInfo &u)
// Build the directory and filename components of the path
// specified in the gxsURLInfo object.  
{
  return HasFile(u.path, u.dir, u.file);
}
int gxsURL::HasFile(const gxString &path)
// Returns true if the path has a file associated with it.
{
  gxString d, f;
  return HasFile(path, d, f);
}