예제 #1
0
파일: udf1.c 프로젝트: 3aychonok/libcdio
static udf_dirent_t *
list_files(udf_t *p_udf, udf_dirent_t *p_udf_dirent, const char *psz_path)
{
  if (!p_udf_dirent) return NULL;
  
  print_file_info(p_udf_dirent, psz_path);

  while (udf_readdir(p_udf_dirent)) {
      
    if (udf_is_dir(p_udf_dirent)) {
      
      udf_dirent_t *p_udf_dirent2 = udf_opendir(p_udf_dirent);
      if (p_udf_dirent2) {
	const char *psz_dirname = udf_get_filename(p_udf_dirent);
	const unsigned int i_newlen=2 + strlen(psz_path) + strlen(psz_dirname);
	char *psz_newpath = calloc(1, sizeof(char)*i_newlen);
	
	snprintf(psz_newpath, i_newlen, "%s%s/", psz_path, psz_dirname);
	list_files(p_udf, p_udf_dirent2, psz_newpath);
	free(psz_newpath);
      }
    } else {
      print_file_info(p_udf_dirent, NULL);
    }
  }
  return p_udf_dirent;
}
예제 #2
0
파일: myls.c 프로젝트: hyewon20/MyShell
void list_file(char *dir, char *filename)
{
    struct dirent *dirent_pointer;
    struct stat stat_buf;
    DIR *direct;
    direct = opendir(dir);

    if ( direct  == NULL) {
        fprintf(stderr, "myls: cannot open %s\n", dir);
        return;
    } else if (strcmp(".", dir) == 0 && strlen(filename) != 0) {
        while ((dirent_pointer = readdir(direct)) != NULL) {
            if (strcmp(dirent_pointer->d_name, filename) == 0) {
                stat(dirent_pointer->d_name, &stat_buf);
                print_file_info(dirent_pointer, &stat_buf);
            }
        }
        closedir(direct);
        return;
    } else {
        while ((dirent_pointer = readdir(direct)) != NULL) {
            if( strcmp(dirent_pointer->d_name,".") == 0 || strcmp(dirent_pointer->d_name,"..") == 0 )
                continue;

            stat(dirent_pointer->d_name, &stat_buf);

            print_file_info(dirent_pointer, &stat_buf);

        }
        closedir(direct);
        return;
    }
}
예제 #3
0
/*-------------------------------------------------------------------------
 * Function: print_file_statistics
 *
 * Purpose: Prints file statistics
 *
 * Return: Success: 0
 *
 * Failure: Never fails
 *
 * Programmer: Elena Pourmal
 *             Saturday, August 12, 2006
 *
 *-------------------------------------------------------------------------
 */
static void
print_file_statistics(const iter_t *iter)
{
    if(display_all) {
        display_file = TRUE;
        display_group = TRUE;
        display_dset = TRUE;
        display_dset_dtype_meta = TRUE;
        display_attr = TRUE;
        display_summary = TRUE;

        display_file_metadata = TRUE;
        display_group_metadata = TRUE;
        display_dset_metadata = TRUE;
    }

    if(display_file)            print_file_info(iter);
    if(display_file_metadata)   print_file_metadata(iter);

    if(display_group)           print_group_info(iter);
    if(!display_all && display_group_metadata)   print_group_metadata(iter);

    if(display_dset)            print_dataset_info(iter);
    if(display_dset_dtype_meta) print_dset_dtype_meta(iter);
    if(!display_all && display_dset_metadata)   print_dset_metadata(iter);

    if(display_attr)            print_attr_info(iter);
    if(display_summary)         print_storage_summary(iter);
} /* print_file_statistics() */
예제 #4
0
void	get_file_infos(udf_t *p_udf, udf_dirent_t *p_udf_dirent, const char *path, const char *file)
{
	while (udf_readdir(p_udf_dirent))
	{
		const char *dirname = udf_get_filename(p_udf_dirent);
		if (udf_is_dir(p_udf_dirent))
		{
			udf_dirent_t *p_udf_dirent2 = udf_opendir(p_udf_dirent);
			if (p_udf_dirent2)
			{
				const unsigned int i_newlen=2 + strlen(path) + strlen(dirname);
				char *newpath = (char *)calloc(1, sizeof(char)*i_newlen);

				snprintf(newpath, i_newlen, "%s%s/", path, dirname);
				get_file_infos(p_udf, p_udf_dirent2, newpath, file);
				free(newpath);
			}
		}
		else if (strcmp(dirname, file) == 0)
		{
			const unsigned int i_newlen=2 + strlen(path) + strlen(dirname);
			char *newpath = (char *)calloc(1, sizeof(char)*i_newlen);

			snprintf(newpath, i_newlen, "%s%s", path, dirname);
			print_file_info(p_udf_dirent, newpath);
		}
	}
}
예제 #5
0
void	list_files(udf_t *p_udf, udf_dirent_t *p_udf_dirent, const char *path)
{
	if (!p_udf_dirent)
		return;

	//print_file_info(p_udf_dirent, path);

	while (udf_readdir(p_udf_dirent))
	{
		const char *dirname = udf_get_filename(p_udf_dirent);
		if (udf_is_dir(p_udf_dirent))
		{
			udf_dirent_t *p_udf_dirent2 = udf_opendir(p_udf_dirent);
			if (p_udf_dirent2)
			{
				const unsigned int i_newlen=2 + strlen(path) + strlen(dirname);
				char *newpath = (char *)calloc(1, sizeof(char)*i_newlen);

				snprintf(newpath, i_newlen, "%s%s/", path, dirname);
				list_files(p_udf, p_udf_dirent2, newpath);
				free(newpath);
			}
		}
		else
		{
			const unsigned int i_newlen=2 + strlen(path) + strlen(dirname);
			char *newpath = (char *)calloc(1, sizeof(char)*i_newlen);

			snprintf(newpath, i_newlen, "%s%s", path, dirname);
			if (strncmp(location, newpath, strlen(location)) == 0)
				print_file_info(p_udf_dirent, newpath);
		}
	}
}
예제 #6
0
파일: gfrep.c 프로젝트: ddk50/gfarm_v2
static void
print_file_list(struct gfarm_list *list)
{
	int i;

	for (i = 0; i < gfarm_list_length(list); ++i)
		print_file_info(gfarm_list_elem(list, i));
}
예제 #7
0
void printhead(struct fout f, struct rnndb *db) {
	int i, j;
	struct stat sb;
	struct tm tm;
	stat(f.name, &sb);
	gmtime_r(&sb.st_mtime, &tm);
	fprintf (f.file, "#ifndef %s\n", f.guard);
	fprintf (f.file, "#define %s\n", f.guard);
	fprintf (f.file, "\n");
	fprintf(f.file,
		"/* Autogenerated file, DO NOT EDIT manually!\n"
		"\n"
		"This file was generated by the rules-ng-ng headergen tool in this git repository:\n"
		"http://0x04.net/cgit/index.cgi/rules-ng-ng\n"
		"git clone git://0x04.net/rules-ng-ng\n"
		"\n"
		"The rules-ng-ng source files this header was generated from are:\n");
	unsigned maxlen = 0;
	for(i = 0; i < db->filesnum; ++i) {
		unsigned len = strlen(db->files[i]);
		if(len > maxlen)
			maxlen = len;
	}
	for(i = 0; i < db->filesnum; ++i) {
		unsigned len = strlen(db->files[i]);
		fprintf(f.file, "- %s%*s ", db->files[i], maxlen - len, "");
		print_file_info(f.file, db->files[i]);
	}
	fprintf(f.file,
		"\n"
		"Copyright (C) ");
	if(db->copyright.firstyear && db->copyright.firstyear < (1900 + tm.tm_year))
		fprintf(f.file, "%u-", db->copyright.firstyear);
	fprintf(f.file, "%u", 1900 + tm.tm_year);
	if(db->copyright.authorsnum) {
		fprintf(f.file, " by the following authors:");
		for(i = 0; i < db->copyright.authorsnum; ++i) {
			fprintf(f.file, "\n- ");
			if(db->copyright.authors[i]->name)
				fprintf(f.file, "%s", db->copyright.authors[i]->name);
			if(db->copyright.authors[i]->email)
				fprintf(f.file, " <%s>", db->copyright.authors[i]->email);
			if(db->copyright.authors[i]->nicknamesnum) {
				for(j = 0; j < db->copyright.authors[i]->nicknamesnum; ++j) {
					fprintf(f.file, "%s%s", (j ? ", " : " ("), db->copyright.authors[i]->nicknames[j]);
				}
				fprintf(f.file, ")");
			}
		}
	}
	fprintf(f.file, "\n");
	if(db->copyright.license)
		fprintf(f.file, "\n%s\n", db->copyright.license);
	fprintf(f.file, "*/\n\n\n");
}
예제 #8
0
파일: myls.c 프로젝트: ljian1992/Demo
void print_dir_info (const char * dirname)
{
	char file_path[100];
	struct stat buf;
	struct dirent *pTmp;
	int MaxNlink = 1;
	int MaxSize = 0;

	
	DIR *pDir = opendir (dirname);
	//设置打印格式的width
	while ( NULL != (pTmp = (readdir (pDir))) )
	{
		bzero (file_path, sizeof(file_path));
		sprintf (file_path, "%s%s", dirname, pTmp->d_name);
        stat (file_path, &buf);
	    
		if (buf.st_size > MaxSize)
		{
			MaxSize = buf.st_size;
		}

		if (buf.st_nlink > MaxNlink)
		{
			MaxNlink = buf.st_nlink;
		}
		
	}

	MaxSizeDi = get_digit (MaxSize);
	MaxNlinkDi = get_digit (MaxNlink);
	closedir (pDir);

	pDir = opendir (dirname);
	
	while ( NULL != (pTmp = (readdir (pDir))) )
	{
		//获取文件名
		if ( 0 != strcmp (pTmp->d_name, ".") && 
		     0 != strcmp (pTmp->d_name, "..") )
		{
			bzero(file_path, sizeof(file_path));
			sprintf(file_path,"%s/%s", dirname, pTmp->d_name);
			print_file_info (file_path);

		}

	}

	closedir (pDir);
}
예제 #9
0
    int DsLib::check_file_info(DsTask& ds_task)
    {
      GetServerStatusMessage req_gss_msg;
      req_gss_msg.set_status_type(GSS_BLOCK_FILE_INFO);
      req_gss_msg.set_return_row(ds_task.block_id_);

      tbnet::Packet* rsp = NULL;
      NewClient* client = NewClientManager::get_instance().create_client();
      int ret = send_msg_to_server(ds_task.server_id_, client, &req_gss_msg, rsp);

      if (rsp != NULL)
      {
        if (rsp->getPCode() == BLOCK_FILE_INFO_MESSAGE)
        {
          BlockFileInfoMessage* req_bfi_msg = reinterpret_cast<BlockFileInfoMessage*>(rsp);
          FILE_INFO_LIST* file_list = req_bfi_msg->get_fileinfo_list();
          bool found = false;
          for (int32_t i = 0; i < static_cast<int32_t> (file_list->size()); ++i)
          {
            if (file_list->at(i).id_ == ds_task.new_file_id_)
            {
              printf("file found in server: %s\n", tbsys::CNetUtil::addrToString(ds_task.server_id_).c_str());
              tfs::client::FSName fsname(ds_task.block_id_, ds_task.new_file_id_, ds_task.cluster_id_);
              print_file_info(fsname.get_name(), file_list->at(i));
              found = true;
              break;
            }
          }
          if (!found)
          {
            printf("file not found in server: %s\n", tbsys::CNetUtil::addrToString(ds_task.server_id_).c_str());
          }
        }
        else if (rsp->getPCode() == STATUS_MESSAGE)
        {
          printf("get file info fail, error: %s\n", dynamic_cast<StatusMessage*>(rsp)->get_error());
        }
      }
      else
      {
        printf("get NULL respose message, ret: %d\n", ret);
      }

      NewClientManager::get_instance().destroy_client(client);
      return ret;
    }
예제 #10
0
int main(int argc, char **argv)
{
	int ret;
	struct hash_tree tree;

	init_filerec();
	init_hash_tree(&tree);

	if (parse_options(argc, argv)) {
		usage(argv[0]);
		return EINVAL;
	}

	if (init_csum_module(DEFAULT_HASH_STR))
		return ENOMEM;

	ret = dbfile_open(serialize_fname);
	if (ret)
		return ret;

	ret = dbfile_get_config(&disk_blocksize, &disk_hashes, &disk_files,
				&major, &minor);
	if (ret)
		return ret;

	blocksize = disk_blocksize;

	ret = prepare_statements();
	if (ret)
		return ret;

	print_file_info();

	if (num_to_print || print_all_hashes)
		print_by_size();

	if (print_file_list)
		print_filerecs();

	finalize_statements();

	dbfile_close();

	return ret;
}
예제 #11
0
파일: h5stat.c 프로젝트: svn2github/hdf5
/*-------------------------------------------------------------------------
 * Function: print_file_statistics
 *
 * Purpose: Prints file statistics
 *
 * Return: Success: 0
 *
 * Failure: Never fails
 *
 * Programmer: Elena Pourmal
 *             Saturday, August 12, 2006
 *
 *-------------------------------------------------------------------------
 */
static void
print_file_statistics(const iter_t *iter)
{
    if(display_all) {
        display_file = TRUE;
        display_file_metadata = TRUE;
        display_group = TRUE;
        display_dset = TRUE;
        display_dtype_metadata = TRUE;
        display_attr = TRUE;
    }

    if(display_file)          print_file_info(iter);
    if(display_file_metadata) print_file_metadata(iter);
    if(display_group)         print_group_info(iter);
    if(display_dset)          print_dataset_info(iter);
    if(display_attr)          print_attr_info(iter);
}
예제 #12
0
파일: myls.c 프로젝트: yumm007/C
void static print_single_record(const struct stat *file_st, const struct\
	print_f *format, const char *filename) {

	char *p;

	if (is_dot_file(filename) && (format->dot_flag) == DISABLE) 
		return;
	
	print_file_info(file_st, format);
	if ((p = strrchr(filename, '/')) != NULL && \
		p - filename + 1 != strlen(filename))
		printf("%s", p + 1);
	else
		printf("%s", filename);
	printf("%c", format->newl_flag ? '\n': '\t');

	return;
}
예제 #13
0
파일: mast_filecast.cpp 프로젝트: njh/mast
int main(int argc, char **argv)
{
    MastSendTool *tool = NULL;
    SF_INFO sfinfo;


    // Create the send tool object
    tool = new MastSendTool( MAST_TOOL_NAME );
    tool->enable_scheduling();

    // Parse the command line arguments
    // and configure the session
    parse_cmd_line( argc, argv, tool );

    // Open the input file by filename
    memset( &sfinfo, 0, sizeof(sfinfo) );
    g_input_file = sf_open(g_filename, SFM_READ, &sfinfo);
    if (g_input_file == NULL) MAST_FATAL("Failed to open input file:\n%s", sf_strerror(NULL));
    tool->set_input_channels( sfinfo.channels );
    tool->set_input_samplerate( sfinfo.samplerate );

    // Display some information about the input file
    print_file_info( g_input_file, &sfinfo );

    // Setup signal handlers
    mast_setup_signals();

    // Run the main loop
    tool->run();

    // Clean up
    delete tool;


    // Close input file
    if (sf_close( g_input_file )) {
        MAST_ERROR("Failed to close input file:\n%s", sf_strerror(g_input_file));
    }


    // Success !
    return 0;
}
예제 #14
0
파일: main.c 프로젝트: eugen0329/tcp
void receive_file(int sock) {
    char file_name[BUF_SIZE];
    int file_size, buf_size, bytes, readed_bytes = 0;
    FILE *f;

    //receive file name
    readed_bytes = recv(sock, file_name, LENGTH_OF(file_name), 0);
    file_name[readed_bytes] = '\0';
    //receive file size
    file_size = receive_int(sock);
    //receive buf size
    buf_size = receive_int(sock);

    print_file_info(file_name, file_size, buf_size);

    if((f = fopen(file_name, "wb")) == NULL) {
        printf("Can't create file\n");
        return;
    }

    char buf[buf_size];

    do {
        bytes = recv(sock, buf, LENGTH_OF(buf), 0);
        printf("%i\n", bytes);

        // if last package
        if(bytes < buf_size - 1){
            char new_buf[bytes];
            strncpy(new_buf, buf, bytes);
            new_buf[bytes] = '\0';
            fprintf(f, "%s", new_buf);
        } else {
            fprintf(f, "%s", buf);
            fseek(f, readed_bytes, SEEK_SET);
        }
        readed_bytes += bytes;
        printf("%i\n", readed_bytes);
    } while(bytes >= buf_size - 1);

    fclose(f);
}
예제 #15
0
파일: myls.c 프로젝트: ljian1992/Demo
int main (int agrc, char *argv[])
{
	struct stat buf;
	
	stat (argv[1], &buf);

	//判断是否是文件,是则打印文件信息
	if (is_file (buf))
	{
		print_file_info (argv[1]);	
	}

	//若是目录,则打印目录下所有的文件信息,但不包括. ..文件
	if (is_dir (buf))
	{
        	
		print_dir_info (argv[1]);	
	}

	return 0;
}
예제 #16
0
파일: gfrep.c 프로젝트: ddk50/gfarm_v2
static const char *
pfor(struct action *act, int nfinfo, struct file_info **finfo,
	  int nthreads, struct gfrep_arg *arg)
{
	int i, pi, tnum, nth, nerr = 0;
	gfarm_error_t e;
	int ndst = arg->ndst, nsrc = arg->nsrc;
	const char *errmsg;

	if (ndst <= 0)
		return ("no destination node");
	if (nsrc <= 0)
		return ("no source node");
	if (ndst < opt_nrep)
		return ("not enough number of destination nodes");
	if (nfinfo <= 0)
		return (NULL); /* no file */
	/* sort 'sinfo' in descending order wrt file size */
	qsort(finfo, nfinfo, sizeof(*finfo), filesizecmp_inv);

	if (nthreads <= 0) {
		nthreads = nfinfo;
		if (ndst < nthreads)
			nthreads = ndst;
		if (nsrc < nthreads)
			nthreads = nsrc;
	}
	if (opt_verbose) {
		print_gfrep_arg(arg);
		printf("files: %d\n", nfinfo);
#ifdef _OPENMP
		printf("parallel %s in %d threads\n", act->msg, nthreads);
#endif
	}
	omp_set_num_threads(nthreads);

#pragma omp parallel reduction(+:nerr) private(pi, tnum, nth)
	{
	pi = 0;
	tnum = omp_get_thread_num();
	nth = omp_get_num_threads();

#pragma omp for schedule(dynamic)
	for (i = 0; i < nfinfo; ++i) {
		struct timeval t1, t2;
		double t;
		struct file_info *fi = finfo[i];
#ifdef LIBGFARM_NOT_MT_SAFE
		pid_t pid;
		int s, rv;
#endif
		if (opt_noexec || !opt_quiet)
			printf("%s\n", fi->pathname);
		if (opt_verbose)
			print_file_info(fi);
		if (tnum + pi * nth >= ndst)
			pi = 0;

#ifdef LIBGFARM_NOT_MT_SAFE
		pid = fork();
		if (pid == 0) {
			e = gfarm_terminate();
			if (e == GFARM_ERR_NO_ERROR)
				e = gfarm_initialize(NULL, NULL);
			if (e != GFARM_ERR_NO_ERROR) {
				errmsg = gfarm_error_string(e);
				goto skip_replication;
			}
#endif
			if (opt_verbose)
				gettimeofday(&t1, NULL);
			if (!opt_noexec) {
				e = action(act, tnum, nth, pi, fi, arg);
				errmsg = gfarm_error_string(e);
			} else {
				e = GFARM_ERR_NO_ERROR;
				errmsg = gfarm_error_string(e);
			}
			if (opt_verbose && e == GFARM_ERR_NO_ERROR) {
				gettimeofday(&t2, NULL);
				t = gfarm_timerval_sub(&t2, &t1);
				printf("%s: %f sec  %f MB/sec\n",
				       fi->pathname, t,
				       fi->filesize / t / 1024 / 1024);
			}
#ifdef LIBGFARM_NOT_MT_SAFE
 skip_replication:
#endif
			if (e != GFARM_ERR_NO_ERROR) {
#ifndef LIBGFARM_NOT_MT_SAFE
				++nerr;
#endif
				fprintf(stderr, "%s: %s\n",
					fi->pathname, errmsg);
			}
#ifdef LIBGFARM_NOT_MT_SAFE
			fflush(stdout);
			sync();
			_exit(e == GFARM_ERR_NO_ERROR ? 0 : 1);
		}
		while ((rv = waitpid(pid, &s, 0)) == -1 && errno == EINTR)
			;
		if (rv == -1 || (WIFEXITED(s) && WEXITSTATUS(s) != 0))
			++nerr;
#endif
		++pi;
	}
	}
	return (nerr == 0 ? NULL : "error happens during operations");
}
예제 #17
0
    int DsLib::list_file(DsTask& ds_task)
    {
      uint64_t server_id = ds_task.server_id_;
      int32_t cluster_id = ds_task.cluster_id_;
      uint32_t block_id = ds_task.block_id_;
      int32_t mode = ds_task.mode_;

      GetServerStatusMessage req_gss_msg;
      req_gss_msg.set_status_type(GSS_BLOCK_FILE_INFO);
      req_gss_msg.set_return_row(block_id);

      int ret_status = TFS_ERROR;
      NewClient* client = NewClientManager::get_instance().create_client();
      tbnet::Packet* ret_msg = NULL;
      ret_status = send_msg_to_server(server_id, client, &req_gss_msg, ret_msg);

      //if the information of file can be accessed.
      if ((ret_status == TFS_SUCCESS))
      {
        if (BLOCK_FILE_INFO_MESSAGE == ret_msg->getPCode())
        {
          FILE_INFO_LIST* file_info_list = (dynamic_cast<BlockFileInfoMessage*> (ret_msg))->get_fileinfo_list();
          int32_t i = 0;
          int32_t list_size = file_info_list->size();

          //output file information
          printf("FileList Size = %d\n", list_size);
          if (mode != 0)
          {
            printf(
              "FILE_NAME          FILE_ID             OFFSET        SIZE        USIZE       M_TIME               C_TIME              FLAG CRC\n");
            printf(
              "---------- ---------- ---------- ---------- ----------  ---------- ---------- ---------- ---------- ---------- ---------- ----------\n");

            for (i = 0; i < list_size; i++)
            {
              FileInfo& file_info = file_info_list->at(i);
              tfs::client::FSName fsname(block_id, file_info.id_, cluster_id);
              print_file_info(fsname.get_name(), file_info);
            }
            printf(
              "---------- ---------- ---------- ---------- ----------  ---------- ---------- ---------- ---------- ---------- ---------- ----------\n");
            printf(
              "FILE_NAME          FILE_ID             OFFSET        SIZE        USIZE       M_TIME               C_TIME              FLAG CRC\n");

          }
          else
          {
            // just print file
            for (i = 0; i < list_size; i++)
            {
              FileInfo& file_info = file_info_list->at(i);
              tfs::client::FSName fsname(block_id, file_info.id_, cluster_id);
              fprintf(stdout, "\n%s", fsname.get_name());
            }
            fprintf(stdout, "\n");
          }
          printf("Total : %d files\n", list_size);
        }
        else if (STATUS_MESSAGE == ret_msg->getPCode())
        {
          printf("%s", (dynamic_cast<StatusMessage*> (ret_msg))->get_error());
        }
      }
      else
      {
        fprintf(stderr, "Get File list in Block failure\n");
      }

      NewClientManager::get_instance().destroy_client(client);
      return ret_status;

    }
예제 #18
0
extern "C" void __cdecl begin( void )
{
    int multi_link_only = 0;
    int show_usage = 0;
    int was_file_arg = 0;

    HANDLE hStdOut = GetStdHandle(STD_OUT_HANDLE);

    const char * ws = " \t\r\n";
    const wchar_t * pcmdline = next_token(GetCommandLineW(), ws);
#if 0 // echo the remainder of the command line
    int ii = 0;
    char output[1024];
    for (ii = 0; pcmdline[ii]; ++ii) {
       output[ii] = (char)pcmdline[ii];
    }
    if (ii > 0) {
       if ( ! Print(hStdOut, output, ii))
          ExitProcess(GetLastError());
    }
#endif
    while (*pcmdline) {
        int cchArg;
        const wchar_t * pArg;
        const wchar_t * pnext = next_token_ref(pcmdline, ws, pArg, cchArg);
        if (*pArg == '-' || *pArg == '/') {
           const wchar_t * popt = pArg+1;
           for (int ii = 1; ii < cchArg; ++ii) {
              wchar_t opt = pArg[ii];
              switch (opt) {
                 case 'd': hex_filenumber = 0; break;
                 case 'h': show_usage = 1; break;
                 case 'l': label_output = 1; break;
                 case 'm': multi_link_only = 1; break;
                 case 'q': quad_filenumber = 1; break;
                 case 'w': wide_filenumber = 1; break;
                 case '?': show_usage = 1; break;
              }
           }
        } else if (*pArg) {
           was_file_arg = 1;
           // copy arg so that we can strip quotes and end up null terminated.
           wchar_t * filename = AllocCopyZ(pArg, cchArg);
           //char dummy[256]; char* p = append(dummy, "Arg: |"); p = append(p, filename); p = append(p, "|"); p = append_num(p, (unsigned)cchArg); p = append(p, "\r\n");
           //Print(hStdOut, dummy, p);
           HANDLE hFile = CreateFileW(filename, READ_META, FILE_SHARE_ALL, NULL, OPEN_EXISTING, 0, NULL);
           if (hFile != INVALID_HANDLE_VALUE) {
              BY_HANDLE_FILE_INFORMATION bhfi;
              if ( ! GetFileInformationByHandle(hFile, &bhfi)) {
                 ExitProcess(GetLastError());
              }
              CloseHandle(hFile);
              if ( ! multi_link_only || bhfi.nNumberOfLinks > 1) {
                 print_file_info(hStdOut, bhfi, filename);
              }
           }
           Free(filename);
        }
    pcmdline = pnext;
    }

    if (show_usage || ! was_file_arg) {
       Print(hStdOut,
           BUILD_MODULE_STRING " v" BUILD_VERSION_STRING " " BUILD_ARCH_STRING "  Copyright 2015 HTCondor/John M. Knoeller\r\n"
           "Usage: has_links [options] <file> [<file2> ...]\r\n"
           "    prints the number of hardlinks and the inode value of <file>'s\r\n"
           " [options] is one or more of\r\n"
           "   -d print inode as decimal value (default is hex)\r\n"
           "   -l label items\r\n"
           "   -m print only if inode has multiple links\r\n"
           "   -q print inode as a single 64bit value\r\n"
           "   -w print wide format inode\r\n"
           "   -h print usage (this output)\r\n"
           "\r\n" , -1);
    }

    ExitProcess(0);
}