LLVM API Documentation

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

Path.cpp

Go to the documentation of this file.
00001 //===-- Path.cpp - Implement OS Path Concept --------------------*- C++ -*-===//
00002 // 
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file was developed by Reid Spencer and is distributed under the 
00006 // University of Illinois Open Source License. See LICENSE.TXT for details.
00007 // 
00008 //===----------------------------------------------------------------------===//
00009 //
00010 //  This header file implements the operating system Path concept.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #include "llvm/System/Path.h"
00015 #include <cassert>
00016 
00017 namespace llvm {
00018 using namespace sys;
00019 
00020 //===----------------------------------------------------------------------===//
00021 //=== WARNING: Implementation here must contain only TRULY operating system
00022 //===          independent code. 
00023 //===----------------------------------------------------------------------===//
00024 
00025 LLVMFileType 
00026 sys::IdentifyFileType(const char*magic, unsigned length) {
00027   assert(magic && "Invalid magic number string");
00028   assert(length >=4 && "Invalid magic number length");
00029   switch (magic[0]) {
00030     case 'l':
00031       if (magic[1] == 'l' && magic[2] == 'v') {
00032         if (magic[3] == 'c')
00033           return CompressedBytecodeFileType;
00034         else if (magic[3] == 'm')
00035           return BytecodeFileType;
00036       }
00037       break;
00038 
00039     case '!':
00040       if (length >= 8) {
00041         if (memcmp(magic,"!<arch>\n",8) == 0)
00042           return ArchiveFileType;
00043       }
00044       break;
00045 
00046     default:
00047       break;
00048   }
00049   return UnknownFileType;
00050 }
00051 
00052 }
00053 
00054 // Include the truly platform-specific parts of this class.
00055 #include "platform/Path.cpp"
00056 
00057 // vim: sw=2 smartindent smarttab tw=80 autoindent expandtab